Tena koe Caspar Try removing the (ds==2) - I'm not sure how you expect R to interpret that.
HTH .... Peter Alspach > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of casperyc > Sent: Wednesday, 14 April 2010 10:42 a.m. > To: r-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 > =========================== > > 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, > > 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.