Hello, I realize this is probably a dumb question, but I think there must be an easy way to do this with R and I was not able to find it in the doc. I have a table (read from a file with read.table), with two factor columns, table$A and table$B, and a numerical column, table$X. I wish to make a boxplot of (table$X ~ table$A) for a given value of B. Is there a way to express this with a formula, or is it necessary to manually extract the right lines in the table? In that case, what is the best way to do so? Thanks for your help Alexandre "R newby" Fayolle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Alexandre Fayolle <Alexandre.Fayolle at free.fr> writes:> I realize this is probably a dumb question, but I think there must be an > easy way to do this with R and I was not able to find it in the doc. > > I have a table (read from a file with read.table), with two factor > columns, table$A and table$B, and a numerical column, table$X. I wish to > make a boxplot of (table$X ~ table$A) for a given value of B. Is there > a way to express this with a formula, or is it necessary to manually > extract the right lines in the table? In that case, what is the best way > to do so?The "subset" argument allows you to specify an expression that determines the subset of interest. You would use something like boxplot( X ~ A, data = table, subset = B =="Bvalue" ) By the way, it is not a good idea to call the data "table" because there is a function called table that may need to be used in boxplot. R is smart about this and looks specifically for a function when a function is needed but it is still better to avoid name conflicts if you can. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Alexandre, "help(boxplot)" among other things says: Usage: ... boxplot.formula(formula, data = NULL, subset, na.action, ...) ... So you can use> boxplot(table$X ~ table$A,subset(table$B==given.value))Any logical expression should work. Best ... Uli Flenker Institute of Biochemistry German Sports University Cologne Carl-Diem-Weg 6 50933 Cologne / Germany Phone 0049/0221/4982-493 On Sat, 9 Dec 2000, Alexandre Fayolle wrote:> Hello, > > I realize this is probably a dumb question, but I think there must be an > easy way to do this with R and I was not able to find it in the doc. > > I have a table (read from a file with read.table), with two factor > columns, table$A and table$B, and a numerical column, table$X. I wish to > make a boxplot of (table$X ~ table$A) for a given value of B. Is there > a way to express this with a formula, or is it necessary to manually > extract the right lines in the table? In that case, what is the best way > to do so? > > Thanks for your help > > > Alexandre "R newby" Fayolle > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._