"Wolfgang Koller" <koller2 at fgr.wu-wien.ac.at> writes:> Dear R-Users! > > My aim is to produce boxplots without the outliers included in the > plot. I started to write a function that looks something like: > > myboxplot <-function(x,fa) { > bpdata <- boxplot(x~fa,plot=FALSE) > bpnames <- names(bpdata) > for (JJ in bpnames) { > command <- paste("bpdata$",JJ,"$out <- numeric(0)",sep=""); > eval(command) > } > bxp(bpdata) > } > > Obviously this does not work as I intended since the argument > of eval() should be of type expression. However, with > expression() there is no way to have variable JJ evaluated first. > > Does anybody see a way to solve this problem?bp <- boxplot(..etc..) for (n in names(bp)) bp[[n]]$out<-numeric(0) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear R-Users! My aim is to produce boxplots without the outliers included in the plot. I started to write a function that looks something like: myboxplot <-function(x,fa) { bpdata <- boxplot(x~fa,plot=FALSE) bpnames <- names(bpdata) for (JJ in bpnames) { command <- paste("bpdata$",JJ,"$out <- numeric(0)",sep=""); eval(command) } bxp(bpdata) } Obviously this does not work as I intended since the argument of eval() should be of type expression. However, with expression() there is no way to have variable JJ evaluated first. Does anybody see a way to solve this problem? Thanks for any suggestions! Wolfgang Koller P.S.: Similar problems with expression() can arise with producing annotations in plots. ---------------------------------------------------------- Wolfgang Koller, koller2 at fgr.wu-wien.ac.at Research Institute for European Affairs Vienna University of Economics and Business Administration Althanstrasse 39-45, 1090 Vienna, Austria -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 6 Jul 1999, Wolfgang Koller wrote:> Dear R-Users! > > My aim is to produce boxplots without the outliers included in the > plot. I started to write a function that looks something like: > > myboxplot <-function(x,fa) { > bpdata <- boxplot(x~fa,plot=FALSE) > bpnames <- names(bpdata) > for (JJ in bpnames) { > command <- paste("bpdata$",JJ,"$out <- numeric(0)",sep=""); > eval(command) > } > bxp(bpdata) > } > > Obviously this does not work as I intended since the argument > of eval() should be of type expression. However, with > expression() there is no way to have variable JJ evaluated first.There are various possibilities. One is just to write for(JJ in names(bpdata)) bpdata[[JJ]]$out<-numeric(0) without all that parsing and deparsing. In a situation where this doesn't work you can use substitute() for(nn in names(bpdata){ command<-substitute(expression(bpdata$JJ$out<-numeric(0)),list(JJ="1")) eval(eval(command)) } This sort of thing is sometimes useful for annotating plots. Thomas Lumley Assistant Professor, Biostatistics University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._