I want to display cumulative summary functions with lattice. First I tried to get cumulated data: library(lattice) data(barley) d.cum <- with( barley, by( yield, INDICES=list(site=site,year=year), FUN=cumsum ) ) I got a list of vectors. I tried to get a dataframe which I could use in xyplot. But neither of the following functions led to the goal: d.cum.df1 <- as.data.frame.list( d.cum ) d.cum.df2 <- as.data.frame.array( d.cum ) Then I tried to solve my problem within the panel function. But now I had to set a value for ylim. test.xyplot <- function( data=barley, yr=1931, ymax=600, type='l', ... ){ print( xyplot( data=data, subset=year==yr , type=type , panel=function( x, y, ... ){ panel.xyplot( x, cumsum(y), ... ) } , ylim=c( 0, ymax ) , yield ~ variety | site , scales=list( x=list( alternating=1, rot=90 ) ) , ... )) } What could I do to get a dataframe containing the cumulative values of ``yield'' which I could use to get the cumulative summary plots? Thanks - Wolfram
Hi! To get a data.frame as.data.frame(do.call("rbind",d.cum)) Sincerely Eryk *********** REPLY SEPARATOR *********** On 6/11/2004 at 9:17 AM Wolfram Fischer wrote:>>>I want to display cumulative summary functions with lattice. >>> >>>First I tried to get cumulated data: >>> library(lattice) >>> data(barley) >>> >>> d.cum <- with( barley, by( yield, INDICES=list(site=site,year=year), >>>FUN=cumsum ) ) >>> >>>I got a list of vectors. >>>I tried to get a dataframe which I could use in xyplot. >>>But neither of the following functions led to the goal: >>> >>> d.cum.df1 <- as.data.frame.list( d.cum ) >>> d.cum.df2 <- as.data.frame.array( d.cum ) >>> >>> >>>Then I tried to solve my problem within the panel function. >>>But now I had to set a value for ylim. >>> >>> test.xyplot <- function( data=barley, yr=1931, ymax=600, type='l', >>>... ){ >>> print( xyplot( data=data, subset=year==yr >>> , type=type >>> , panel=function( x, y, ... ){ >>> panel.xyplot( x, cumsum(y), ... ) >>> } >>> , ylim=c( 0, ymax ) >>> , yield ~ variety | site >>> , scales=list( x=list( alternating=1, rot=90 ) ) >>> , ... >>> )) >>> } >>> >>>What could I do to get a dataframe containing the cumulative values >>>of ``yield'' which I could use to get the cumulative summary plots? >>> >>>Thanks - Wolfram >>> >>>______________________________________________ >>>R-help at stat.math.ethz.ch mailing list >>>stat.math.ethz.ch/mailman/listinfo/r-help >>>PLEASE do read the posting guide! R-project.org/posting-guide.htmlDipl. bio-chem. Eryk Witold Wolski @ MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: wolski at molgen.mpg.de ---W-W---- molgen.mpg.de/~wolski
Apparently Analagous Threads
- lattice: defining an own function using args for "formula" and "groups"
- lattice: showing panels for factor levels with no values
- ggplot2: Controlling line width of panel borders
- converting lists got by tapply to dataframes
- Adding ranks to a repeatedly ragged array