===
myf=function(ds=1){
x=rnorm(10)
y=rnorm(10)
{ #start of if
if (ds==1)
{
list(x,y)
}
else (ds==2)
{
plot(x,y)
}
} # end of if
} # end of function
===
Hi All,
the problem i am having here is,
that I want to be able to control the display,
lf
-help@r-project.org
Subject: [R] writing function ( 'plot' and 'if') problem
===
myf=function(ds=1){
x=rnorm(10)
y=rnorm(10)
{ #start of if
if (ds==1)
{
list(x,y)
}
else (ds==2)
{
plot(x,y)
}
} # end of if
} # end of function
what i am triyng to do is
when ds=1
give me a list
ds=2
plot
Thanks
casper
--
View this message in context:
http://n4.nabble.com/writing-function-plot-and-if-problem-tp1839091p1839125.html
Sent from the R help mailing list archive at Nabble.com.
On Apr 13, 2010, at 5:41 PM, casperyc wrote:
===
myf=function(ds=1){
x=rnorm(10)
y=rnorm(10)
{ #start of if
if (ds==1)
{
list(x,y)
}
else (ds==2)
?if
That seems odd. I would expect this function to return TRUE or FAKSE
rather than proceeding to a plot function.
On Apr 13, 2010, at 5:41 PM, casperyc wrote:
===
myf=function(ds=1){
x=rnorm(10)
y=rnorm(10)
{ #start of if
if (ds==1)
{
list(x,y)
}
else (ds==2)
{
plot(x,y)
}
} # end of if
} # end of function
===
Hi All,
the problem i am having here is,
The spurious condition (ds==2) is actually interpreted as the action taken
by the else statement.
Then the braced plot statement is seen as the next statement after the
conclusion of the
if () {} else ()
statement.
[[alternative HTML version deleted]]
On Apr 13, 2010, at 10:58 PM, RICHARD M. HEIBERGER wrote:
The spurious condition (ds==2) is actually interpreted as the action
taken by the else statement.
Then the braced plot statement is seen as the next statement after
the conclusion of the
if () {} else ()
statement.
I did
7 matches
Mail list logo