On Thu, Sep 1, 2011 at 7:53 PM, Changbin Du <changb...@gmail.com> wrote: > HI, Dear R community, > > I want to split a data frame by using two variables: let and g > It's not clear what you want to do, but investigate the following:
> require(plyr) Loading required package: plyr > ddply(x, .(let, g), function(y) mean(y$g)) let g V1 1 a 1 1 2 a 2 2 3 b 1 1 4 b 2 2 5 c 1 1 6 c 2 2 7 d 1 1 8 d 2 2 9 e 1 1 10 e 2 2 This splits the df in groups of unique 'let' and 'g', and computes the mean for each such group. Regards Liviu ______________________________________________ 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.