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,
that I want to be able to control the display,
lf ds=1, i want to just have a list,a
Perhaps taking out the entirely extraneous condition for else and
"linking up" the else clause:
myf=function(ds=1){
x=rnorm(10)
y=rnorm(10)
#start of if
if (ds==1)
{
list(x,y)
} else {
plot(x,y) }
} # end of if
> myf(1)
[[1]]
[1] -0.5738623 0.6937577 -1.0801386 0.9465693 1.0054440
-1.5523713 1.5912727 0.5426036 1.8980418 -0.5922542
[[2]]
[1] -1.4519795 -0.1556495 -2.5242081 -0.6671736 0.5947123
-0.6051199 -1.3711271 0.1647910 0.1616131 -0.2563056
--
David.
but it seem to always plot...
Thanks.
casper
--
View this message in context:
http://n4.nabble.com/writing-function-plot-and-if-problem-tp1839091p1839091.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.