Chuck Cleland
2006-Nov-23 11:23 UTC
[R] loess lines in xyplot with two or more variables on the left side of a formula
Hello: I recall something like this being discuss recently, but I can't seem to locate an example in the archives. I have data like the following: df <- expand.grid(1:4, 1992:2002) names(df) <- c("MSA", "YEAR") df$IDUPREV <- runif(44) df$VALIDAT <- rnorm(44) I want to create an xyplot() with separate loess lines for each series (IDUPREV and VALIDAT) in the same panel. I'm able to plot each series in the same panel like this: library(lattice) xyplot(IDUPREV + VALIDAT ~ YEAR | MSA, data = df, panel = panel.superpose, type="l") How could I change that so that panel.loess() is applied separately to each series? thanks, Chuck Cleland -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
Gabor Grothendieck
2006-Nov-23 12:51 UTC
[R] loess lines in xyplot with two or more variables on the left side of a formula
Try this: xyplot(IDUPREV + VALIDAT~ YEAR | MSA, data = df, type= c("smooth", "o")) On 11/23/06, Chuck Cleland <ccleland at optonline.net> wrote:> Hello: > I recall something like this being discuss recently, but I can't seem > to locate an example in the archives. I have data like the following: > > df <- expand.grid(1:4, 1992:2002) > names(df) <- c("MSA", "YEAR") > df$IDUPREV <- runif(44) > df$VALIDAT <- rnorm(44) > > I want to create an xyplot() with separate loess lines for each series > (IDUPREV and VALIDAT) in the same panel. I'm able to plot each series > in the same panel like this: > > library(lattice) > > xyplot(IDUPREV + VALIDAT ~ YEAR | MSA, data = df, > panel = panel.superpose, type="l") > > How could I change that so that panel.loess() is applied separately to > each series? > > thanks, > > Chuck Cleland > > -- > Chuck Cleland, Ph.D. > NDRI, Inc. > 71 West 23rd Street, 8th floor > New York, NY 10010 > tel: (212) 845-4495 (Tu, Th) > tel: (732) 512-0171 (M, W, F) > fax: (917) 438-0894 > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >