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
xyplot() or splom()?: two factors from same data frame
3 messages · Duncan Mackay, Rich Shepard
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.
On Fri, 21 Oct 2011, Duncan Mackay wrote:
Without a dataset I am not sure what you need.
Duncan, Part of the problems I'm trying to resolve come from changing priorities from my client and the regulators. I end up stopping one process and starting on a different one. But, that's life in the real world of environmental consulting. :-) What I need now is to compare TDS (total dissolved solids) with specific conductivity and the ions that are normally comprise TDS. Before running any regression models I need to look at these data from three points of view: all data from all sites collected during the past 30 years; average (or total) concentrations (not yet decided on what makes the most ecological sense) within a stream having multiple collection sites; and by site within certain streams. I think that I need to subset the data frame to create distinct analytical data frames for each comparison, then rm() them until needed again (or I'd have a very large number of files in the directory). If I have a subset, for example, of TDS and conductivity regardless of sample date or location I will have two columns of numbers that will fit the xyplot() formula; e.g., xyplot(TDS ~ Cond). This is the broad picture. I can then use the hydrographic basins (2 of 'em) or streams (24 of 'em) as factors to condition the analysis. Repeat for other parameter pairs (TDS vs. Ca, TDS vs, Mg, etc.). Another part of the issue, perhaps, is that the data are in a single data frame: str(chemdata) 'data.frame': 47244 obs. of 6 variables: $ site : Factor w/ 143 levels "BC-0.5","BC-1",..: 134 134 134 127 127 $ sampdate: Date, format: "2006-12-06" "2006-12-06" ... $ param : Factor w/ 66 levels "AGP","ANP","ANP/AGP",..: 58 66 12 24 59 66 $ quant : num 1.08e+04 7.95 1.80e-02 2.80e+02 1.90e+01 8.44 1.62e+03 $ stream : Factor w/ 24 levels "BCrk","CCrk",..: 4 4 4 21 21 21 4 $ basin : Factor w/ 2 levels "BasinEast","BasinWest": 1 1 1 1 1 1 1 1 1 2 ... while all the data sets used in the books I've read are simpler. What I've not read is guidance on how complex data sets could (or should) be partitioned into smaller but still related data sets to facilitate analyses. I hope this clarifies my initial request. Rich