Rich Shepard
2011-Oct-20 23:41 UTC
[R] xyplot() or splom()?: two factors from same data frame
I'm not seeing how to plot the quantities associated with two values of a factor by reading the ?xyplot help page and Deepayan's book. Perhaps I need to generate many different subsets from the data frame, but that would require _many_ new data frames. The structure of the data frame (for a single stream) has sites (factor), a date (as.Date), parameters (factor), and quantities (numeric). What I need to do is produce scatter plots of the quantities associated with two different parameters conditioned by site or by date (separate plots, I'm sure). I have 24 streams and initially need to look at the relationships of 5 different pairs of parameters (e.g., "Cond" and "TDS") for all sites and by sites. Can I do this from the existing data frame? It seems to me that a splom() could be ideal for this, but I still have the question of how to specify quantities for two parameters to plot against each other. Rich
Duncan Mackay
2011-Oct-21 01:06 UTC
[R] xyplot() or splom()?: two factors from same data frame
Hi Rich Without a dataset I am not sure what you need. Further down the track you will need to plot what you finally need and this may help you decide what you need now for finals try library(lattice) library(latticeExtra) useOuterStrips( xyplot(variable1 + variable2 ~ Date|Site, data = Data, groups = Groups, ...) ) this will give you a matrix plot of the columns being the site and the rows being the variables. but for now if you have a large screen you can do a splom by sites you may to subset sites. use par.settings and levelplot settings to reduce the fontsizes etc so that you can get as much information splom( ...|Site, data= Data,...) if you want to have 2 plots eg the x axis as time and another independent variable you can plot them on the page together eg plot1 <- xyplot(....) plot2 <- density.plot(...) print(p1, position= c(0,0,1,0.5), more = T) print(p1, position= c(0,0.5,1,1), more = F) see ?print.trellis As usual everything depends on the data HTH Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email Home: mackay at northnet.com.au At 09:41 21/10/2011, you wrote:> I'm not seeing how to plot the quantities associated with two values of a >factor by reading the ?xyplot help page and Deepayan's book. Perhaps I need >to generate many different subsets from the data frame, but that would >require _many_ new data frames. > > The structure of the data frame (for a single stream) has sites (factor), >a date (as.Date), parameters (factor), and quantities (numeric). What I need >to do is produce scatter plots of the quantities associated with two >different parameters conditioned by site or by date (separate plots, I'm >sure). > > I have 24 streams and initially need to look at the relationships of 5 >different pairs of parameters (e.g., "Cond" and "TDS") for all sites and by >sites. Can I do this from the existing data frame? > > It seems to me that a splom() could be ideal for this, but I still have >the question of how to specify quantities for two parameters to plot against >each other. > >Rich > >______________________________________________ >R-help at 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. >