'How to apply the ICC function to multiple groups?
I'm pretty new to programming and using R so please bear with me. I am trying to use the ICC function (psych package) to get some reliability values for my data. I have about 300 unique IDs and for each ID I have 9x2 ratings (so a total of 3 columns labeled "ID", "rater1", and "rater2"). My goal is to group the ratings by ID and then use the ICC function on the rater values.
I tried to use group_by() like so:
datafile <- read.csv("~filename", header = TRUE)
groupdf <- datafile %>%
group_by(ID)
ICC(groupdf)
But I got this error message:
Error in if (!is.data.frame(groups) || tail(names(groups), 1L) != ".rows") { : missing value where TRUE/FALSE needed
I tried to use split(), and I ended up with a list of data frames, each data frame containing the listener ID and their corresponding ratings. I created a for loop to iterate over each data frame like this:
groupdf <- datafile %>%
split(.$ID)
for(i in 1:length(groupdf))
{
ratings <- groupdf[, c(2, 3)]
ICC(ratings)
print(ICC(ratings))
}
But I get this error:
Error in groupdf[, c(2, 3)] : incorrect number of dimensions
I get the same error if I try to use lapply(). It makes no difference whether I change the column numbers in the code.
At this point I think I'm at the limit of my syntax skills. Can anyone help me see what is missing here? Thank you for your help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
