Search code examples
riccpsych

ICC in psych package: Error in stack.data.frame(x) : no vector columns were selected


I am trying to calculate the ICC using ICC in the psych package. I have scans, which 3 raters measured (rater C, L, N below). I think I formatted my matrix incorrectly.

My code:

data=read.csv("SLICER_FAINT_ICC.csv")
label(data$Scan)="CT Scan"
label(data$Rater.C)="C"
label(data$Rater.L)="L"
label(data$Rater.N)="N"
x<-as.matrix(data)
ICC(x)`

The error: Error in stack.data.frame(x) : no vector columns were selected

My matrix looks like this:

    print(x)
       Scan      Rater.C    Rater.L    Rater.N   
  `[1,] "FA001FU" "1202.450" "1136.550" "1138.860"`
  `[2,] "FA001IN" "1152.660" "1119.520" "1094.260"` 
  `[3,] "FA002FU" "1209.220" "1102.660" "1149.670"`

What am I doing wrong?


Solution

  • ICC() is expecting a matrix of all numbers, but when you include the text column Scan in the matrix and since a matrix can only have one variable type, it converts all the values to strings.

    Remove the column Scans and then it should work. Here's an example with the relevant code:

    #remove the Scan column
    data$Scan<-NULL
    
    #now this should work
    x<-as.matrix(data)
    ICC(x)