[R] Calculating Mean
Rui Barradas
ruipbarradas at sapo.pt
Mon Jun 3 12:20:16 CEST 2013
Hello,
Like Ivan said, you should give us a data example, the best way is to do
it is to paste the output of ?dput in a post. If your data frame is
named 'dat' use the following.
dput(head(dat, 50)) # paste the output of this in a post
As for the question, here is an example using ?aggregate, with fake data.
dat <- data.frame(X = rnorm(100), A = sample(8, 100, TRUE))
aggregate(X ~ A, data = dat, FUN = mean)
Hope this helps,
Rui Barradas
Em 03-06-2013 10:15, Laura Thomas escreveu:
> Hi All,
>
> Sorry about this quite basic, but I am very new to R.
>
> I have a data file which has a dependent variable (reaction time) and a couple of independent variables, one of which is coded 1-8; I want to calculate the reaction time for each of the 8 codes of the independent variable.
>
> Thanks for any help,
>
> Laura
>
> ______________________________________________
> 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