Dear Jake,

An easy way to find the value of one variable by different levels of
another is using by().  For example, turning to the good old mtcars
data again:

> by(mtcars$mpg, factor(mtcars$cyl), mean)
factor(mtcars$cyl): 4
[1] 26.66364
------------------------------------------------------------
factor(mtcars$cyl): 6
[1] 19.74286
------------------------------------------------------------
factor(mtcars$cyl): 8
[1] 15.1

Which can be easily expanded:

# You can look at the output on your own
by(mtcars$mpg, INDICES = list(factor(mtcars$cyl), factor(mtcars$am)), mean)

In short, the first argument is the data, the second argument is a
list of the variables by which to calculate, the third argument, which
is some function.  In this case, the mean.

Is this what you wanted, or did you want something specifically from
the ANOVA model?

Cheers,

Josh

On Wed, Oct 6, 2010 at 1:41 PM, Jake Kami <jakejk...@gmail.com> wrote:
> dear list,
>
> is there any function in R with which i can compute subject-wise means for a
> single factor level? for instance, i wanna have the mean for each subject
> for the first level of factor A, how can i get that? is there a
> straightforward way to solve this problem?
>
>
> kind regards
>
> jake
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
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