Syntax Help for xyplot()
The following might not be exactly the way to do this, but see the package
"reshape" and the line of code following your data:
df <- structure(list(site = structure(c(1L, 1L, 2L, 4L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("BC-0.5", "BC-2", "BC-3",
"BC-4"), class = "factor"), sampdate = structure(c(11L, 11L,
5L, 12L, 7L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 8L), .Label = c("1994-01-20",
"1994-02-17", "1994-03-24", "1994-06-13", "1994-07-25", "1994-08-18",
"1994-10-19", "1994-10-20", "1995-03-16", "1995-06-21", "1996-06-02",
"1996-08-23"), class = "factor"), param = structure(c(2L, 3L,
1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Cond",
"SO4", "TDS"), class = "factor"), quant = c(194, 530, 826, 36,
848, 1795, 640, 406, 401, 441, 400, 393, 420, 438)), .Names = c("site",
"sampdate", "param", "quant"), class = "data.frame", row.names = c("82",
"83", "6903", "6905", "6977", "6980", "6983", "7833", "7838",
"7847", "7854", "7866", "7871", "7877"))
library(reshape)
cast(melt(df), site + sampdate ~ param )
Using site, sampdate, param as id variables
site sampdate Cond SO4 TDS
1 BC-0.5 1996-06-02 NA 194 530
2 BC-2 1994-07-25 826 NA NA
3 BC-2 1994-10-19 848 NA NA
4 BC-2 1995-03-16 1795 NA NA
5 BC-2 1995-06-21 640 NA NA
6 BC-3 1994-01-20 406 NA NA
7 BC-3 1994-02-17 401 NA NA
8 BC-3 1994-03-24 441 NA NA
9 BC-3 1994-06-13 400 NA NA
10 BC-3 1994-07-25 393 NA NA
11 BC-3 1994-08-18 420 NA NA
12 BC-3 1994-10-20 438 NA NA
13 BC-4 1996-08-23 NA 36 NA
Rich Shepard wrote:
On Mon, 24 Oct 2011, B77S wrote:
Why not format the data like this: site sampledate SO4 TDS NA Mg Cond Cl Ca
Because I don't know how to reformat the base data frame (chemdata) to achieve this.
It seems to me that you summary doesn't make any sense. Those quantiles are meaningless as they encompass all the parameters. Am I missing something?
One site/sampdate/param has one value associated with it.
82 BC-0.5 1996-06-02 SO4 194.00 83 BC-0.5 1996-06-02 TDS 530.00 6903 BC-2 1994-07-25 Cond 826.00 6905 BC-4 1996-08-23 SO4 36.00 6977 BC-2 1994-10-19 Cond 848.00 6980 BC-2 1995-03-16 Cond 1795.00 6983 BC-2 1995-06-21 Cond 640.00 7833 BC-3 1994-01-20 Cond 406.00 7838 BC-3 1994-02-17 Cond 401.00 7847 BC-3 1994-03-24 Cond 441.00 7854 BC-3 1994-06-13 Cond 400.00 7866 BC-3 1994-07-25 Cond 393.00 7871 BC-3 1994-08-18 Cond 420.00 7877 BC-3 1994-10-20 Cond 438.00
I acknowledge that if the chemicals ('param') were in a vector, their
associated
concentrations ('quant') in another vector following it, and both
associated
with a site and sampdate life would be much better.
Thanks,
Rich
______________________________________________ R-help@ 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.
-- View this message in context: http://r.789695.n4.nabble.com/Syntax-Help-for-xyplot-tp3934533p3934857.html Sent from the R help mailing list archive at Nabble.com.