Jinn54
Jinn54

Reputation: 11

Calculating mean values across groups in R

sorry for the beginner question in advance. I searched for an answer, but couldn't find a fitting one.

I have over 20 groups of 6 subjects each, all participating in the same study. All groups had the same test conditions and answered a number of items. I want a mean value per Item across all groups, considered for possible effects within the groups. Or does this average out anyway with the number of groups?

It's a data frame with the heading "group" "Item1" "Item2" "Item3" "..."

edit: This question was not answered in the thread above unfortunately

Upvotes: 0

Views: 57

Answers (1)

Chechy Levas
Chechy Levas

Reputation: 2312

To give you an example of self contained (reproducible) code, and an answer to what I think is your question:

myData <- data.frame(item1 = runif(n=10), item2 = rnorm(n=10), item3 = rt(n=10, df = 1))

means <- apply(myData, 2, mean)

print(means)

If this does not answer your question, then start by editing the above code to more accurately reflect the shape of your data, and give an example of the output.

Upvotes: 2

Related Questions