我正在尝试在likert函数中使用分组参数,但是出现了错误:
lik <- likert(df2, grouping = df$CAR)
Error in sum(x) : invalid 'type' (character) of argument
这是我的简单代码:
library(likert)
df<- fread("C:/R/temp/likert_test.csv", select = 1:6)
df <- as.data.frame(df)
col_names <- names(df[1:6])
df[,col_names] <- lapply(df[,col_names] , factor)
str(df)
'data.frame': 19331 obs. of 6 variables:
$ CAR : Factor w/ 34 levels "Alfa Romeo","Audi",..: 4 4 4 4 3 3 3 3 4 4 ...
$ E1.Overall Satisfaction : Factor w/ 10 levels "1","2","3","4",..: 8 8 8 9 9 7 10 8 7 10 ...
$ E2.Exterior Styling : Factor w/ 10 levels "1","2","3","4",..: 9 8 8 10 8 4 10 8 7 10 ...
$ E2.Overall Quality : Factor w/ 10 levels "1","2","3","4",..: 8 8 7 10 10 8 10 8 8 10 ...
$ E2.Interior Styling : Factor w/ 10 levels "1","2","3","4",..: 9 6 9 10 9 8 9 8 7 10 ...
$ E2.Quality Of Interior And Materials Used Inside The Car: Factor w/ 10 levels "1","2","3","4",..: 7 6 7 10 10 8 10 7 7 10 ...
df2 <- df[,2:5]
lik <- likert(df2, grouping = df$CAR)