Hello R Folks...

I have a list with the following structure:

> str(df)
List of 3
 $ y    : num [1:4, 1:1242] -0.005379 0.029874 -0.023274 0.000655 -0.004537
..
 $ x    : num [1:1242] 501 503 505 507 509 ...
 $ names: Factor w/ 4 levels "PC Loading 1",..: 1 2 3 4

I want to plot each row of df$y against df$x, and have each plot in it¹s own
panel according to the levels of df$names.  The following works in the sense
that the layout is right, but the y values have clearly been recycled or
skipped in some fashion (and an error is thrown for each panel that the
length of x and y aren¹t the same):

p <- xyplot(y ~ x | names, data = df, main = title,
        layout = c(1, dim(y)[1])

In reviewing the extended formula interface in the Lattice Book, what I want
to happen is y1 + y2 + y3 + y4 ~ x | names, outer = TRUE

I see two options: figure out a way to create the extended formula on the
fly (and the actual number of rows in y may vary), which seems potentially
tricky, or create a data frame by stacking each row of y and repeating x and
names to match.  This seems like a waste of memory.

I¹ve looked through the archives and haven¹t come across something quite
like this, or at least I don¹t recognize it if I have!  Is there a more
elegant way to tell xyplot I want to use each row of y repeatedly with the
same x, in a loop-like fashion?

TIA.  Bryan
*************
Bryan Hanson
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to