Hello, I would like to use by to create a series of plots, but I'm not sure how to design the function. Here's what I've got: 1. A data frame of observations of measured value 2 measured vlaues and a pch code. V1 V2 pchCode .0045 123 1 .0034 145 2 .0045 123 1 .0046 167 3 ... So what I want to do is create a single scatterplot of the multiple conditions (specified by pchCode) and use pchCode to specify the plotting character within the plotting function. I'm imagining something like by(df, pchCode, function(x) plot(V1, V2, pch=pchCode)) What I don't know how to code is: 1. getting the pch to be defined by the pchCode 2. specifying that par(new=TRUE) within the by command. Thanks for you suggestions, Best, David S. David White sdavidwhite at bigfoot.com Columbus, Ohio -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
%You are making something easy into something difficult. All you need %is. . . You are _so_ right! Thanks for setting me straight on how to use plot sensibly. S. David White sdavidwhite at bigfoot.com Columbus, Ohio On 28 Aug 2001, Douglas Bates wrote: %David White <dwhite at ling.ohio-state.edu> writes: % %> I would like to use by to create a series of plots, but I'm not sure how %> to design the function. %> %> Here's what I've got: %> %> 1. A data frame of observations of measured value 2 measured vlaues and a %> pch code. %> %> V1 V2 pchCode %> .0045 123 1 %> .0034 145 2 %> .0045 123 1 %> .0046 167 3 %> ... %> %> So what I want to do is create a single scatterplot of the multiple %> conditions (specified by pchCode) and use pchCode to specify the plotting %> character within the plotting function. %> %> I'm imagining something like %> %> by(df, pchCode, function(x) plot(V1, V2, pch=pchCode)) %> %> What I don't know how to code is: %> 1. getting the pch to be defined by the pchCode %> 2. specifying that par(new=TRUE) within the by command. % %You are making something easy into something difficult. All you need %is % %> ttt % V1 V2 pchCode %1 0.0045 123 1 %2 0.0034 145 2 %3 0.0045 123 1 %4 0.0046 167 3 %> str(ttt) %`data.frame': 4 obs. of 3 variables: % $ V1 : num 0.0045 0.0034 0.0045 0.0046 % $ V2 : num 123 145 123 167 % $ pchCode: num 1 2 1 3 %> plot(V2 ~ V1, data = ttt, pch = pchCode) %> # if pchCode is a factor, use as.integer(pchCode) % %Arguments like pch are vectorized. % -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I do not think that you are looking for this: xx <- data.frame(x=rnorm(100),y=rnorm(100),p=1:4) by(xx,xx$p,function(x){par(new=T);plot(x$x,x$y,pch=x$p)}) this dosn't make sence. Perhaps you are looking for: plot(xx$x,xx$y,pch=xx$p) p. On Tue, Aug 28, 2001 at 11:14:37AM -0400, David White wrote:> > > Hello, > > I would like to use by to create a series of plots, but I'm not sure how > to design the function. > > Here's what I've got: > > 1. A data frame of observations of measured value 2 measured vlaues and a > pch code. > > V1 V2 pchCode > .0045 123 1 > .0034 145 2 > .0045 123 1 > .0046 167 3 > ... > > So what I want to do is create a single scatterplot of the multiple > conditions (specified by pchCode) and use pchCode to specify the plotting > character within the plotting function. > > I'm imagining something like > > by(df, pchCode, function(x) plot(V1, V2, pch=pchCode)) > > What I don't know how to code is: > 1. getting the pch to be defined by the pchCode > 2. specifying that par(new=TRUE) within the by command. > > Thanks for you suggestions, > > Best, > > David > > > S. David White > sdavidwhite at bigfoot.com > Columbus, Ohio > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- P.Malewski, Limmerstr.47, 30451 Hannover, 0511-2135008 At work: http://www.MH-Hannover.de 0511 532 3194 / Fax: 0511 532 3190, P.Malewski at tu-bs.de, peter.malewski at gmx.de, malewski.peter at mh-hannover.de. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._