[R] Mean according to the combination of two factors

Rui Barradas ruipbarradas at sapo.pt
Sat Jan 12 00:56:35 CET 2013


Hello,

Try the following.

# make up some data
dat <- data.frame(values = rnorm(100), experiment = sample(10, 100, 
TRUE), composite = sample(17, 100, TRUE))
aggregate(values ~ experiment + composite, data = dat, FUN = mean)


Hope this helps,

Rui Barradas
Em 11-01-2013 23:26, li li escreveu:
> Dear all,
>     I have a data frame where there are three variables: values, experiment,
> composite.
> Values are numerical values. There are 10 levels for the experiment. Within
> each level of experiment,
> there are 17 levels of composite.
>    I want to find mean for each combination of levels of the experiment and
> the levels of composite.
>    Can anyone give some help here.
>    Thank you, Hanna
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list