1
我得到錯誤「已更換4行,數據有2個」當我嘗試了likert
對象創建上運行summary()
,faceLikertG
:
# Group Item angry neutral happy
#1 boys child 19.54023 48.27586 32.18391
#2 boys primary caregiver 27.58621 36.78161 35.63218
#3 girls child 35.18519 31.48148 33.33333
#4 girls primary caregiver 33.94495 32.11009 33.94495
#5 <NA> child 0.00000 0.00000 0.00000
#6 <NA> primary caregiver 0.00000 0.00000 0.00000
我想this issue可能有關係,但我不確定。
faceLikertG <- structure(list(results = structure(list(Group = structure(c(1L,
1L, 2L, 2L, NA, NA), .Label = c("boys", "girls"), class = "factor"),
Item = structure(c(1L, 2L, 1L, 2L, 1L, 2L), .Label = c("child",
"primary caregiver"), class = "factor"), angry = c(19.5402298850575,
27.5862068965517, 35.1851851851852, 33.9449541284404, 0,
0), neutral = c(48.2758620689655, 36.7816091954023, 31.4814814814815,
32.1100917431193, 0, 0), happy = c(32.183908045977, 35.632183908046,
33.3333333333333, 33.9449541284404, 0, 0)), .Names = c("Group",
"Item", "angry", "neutral", "happy"), row.names = c(NA, -6L), class = "data.frame"),
items = structure(list(child = structure(c(2L, 2L, 1L, 2L,
3L, 3L, 2L, 3L, 3L, 2L, 3L, 1L, 1L, 3L, 3L, 3L, 2L, 2L, 1L,
1L, 1L, 1L, 3L, 2L, 2L, 3L, NA, 2L, 3L, 2L, 2L, 3L, 2L, 3L,
3L, 3L, 2L, 3L, 3L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 3L, 1L,
1L, 2L, 1L, 2L, 2L, 3L, 1L, 1L, 1L, 2L, 3L, 2L, 2L, 1L, 3L,
2L, 3L, 3L, 3L, 2L, 1L, 2L, 3L, 1L, 3L, 2L, 2L, 1L, 2L, 1L,
2L, 3L, 2L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L,
1L, 3L, 3L, 2L, 3L, 1L, 2L, 2L, 3L, 2L, 1L, 2L, 3L, 1L, 2L,
1L, 2L, 1L, NA, 1L, 1L, 2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3L, 2L, 2L, 3L, 3L, 3L, 2L, 1L, 1L, 2L,
1L, 3L, 2L, 3L, 1L, 2L, 2L, 1L, 2L, NA, 1L, 1L, 3L, 2L,
2L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 2L), .Label = c("angry",
"neutral", "happy"), class = "factor")), .Names = c("child",
"primary caregiver"), row.names = c("1", "61", "121", "181",
"241", "301", "361", "421", "481", "541", "601", "661", "721",
"781", "841", "901", "961", "1024", "1084", "1144", "1204",
"1324", "1387", "1450", "1510", "1570", "1630", "1690", "1750",
"1810", "1870", "1993", "2053", "2113", "2173", "2233", "2296",
"2356", "2419", "2479", "2542", "2602", "2662", "2722", "2782",
"2842", "2902", "2962", "3022", "3082", "3142", "3202", "3262",
"3322", "3382", "3442", "3502", "3562", "3622", "3682", "3742",
"3802", "3862", "3922", "3982", "4042", "4102", "4162", "4282",
"4342", "4405", "4465", "4525", "4588", "4648", "4708", "4768",
"4828", "4888", "4948", "5008", "5068", "5128", "5188", "5248",
"5308", "5368", "5428", "5488", "5548", "5608", "5668", "5728",
"5788", "5848", "5908", "5968", "6028", "6088", "6148", "6208",
"6268", "6328", "6388", "6448", "6508", "6568", "6628", "6688",
"6748", "6808", "6871", "6931", "6991", "7051", "7111", "7177",
"7237", "7303", "7363", "7423", "7483", "7543", "7603", "7666",
"7726", "7789", "7849", "7909", "7969", "8029", "8089", "8149",
"8209", "8269", "8329", "8389", "8449", "8509", "8575", "8635",
"8695", "8755", "8815", "8875", "8935", "8995", "9055", "9115",
"9175", "9235", "9295", "9355", "9415", "9475", "NA", "9537",
"9597", "9657", "9717", "9777", "9837", "9897", "9960", "10020",
"10080", "10140", "10200", "10260", "10320", "10380", "10440",
"10500", "10560", "10620", "10680", "10743", "10803", "10866",
"10926", "10986", "11046", "11106", "11166", "11226", "11286",
"11346", "11406", "11466", "11526", "11586", "11646", "11706",
"11766", "11826", "11886", "11946", "12006", "12066"), class = "data.frame"),
grouping = structure(c(2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L,
1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L,
1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L,
2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L,
2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L,
2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, NA, 1L, 2L, 2L,
2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L), .Label = c("boys",
"girls"), class = "factor"), factors = NULL, nlevels = 3L,
levels = c("angry", "neutral", "happy")), .Names = c("results",
"items", "grouping", "factors", "nlevels", "levels"), class = "likert")
會議:
#> sessionInfo()
#R version 3.3.0 (2016-05-03)
#Platform: x86_64-apple-darwin13.4.0 (64-bit)
#Running under: OS X 10.11.5 (El Capitan)
#locale:
#[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#attached base packages:
#[1] parallel stats graphics grDevices utils datasets methods
#[8] base
#other attached packages:
# [1] likert_1.3.3 ......
更新
這裏是一個更好的例子,顯示問題。該錯誤由分組變量中的NA觸發。我不確定這是一個錯誤,還是我應該通過限制來完成分組變量上的事例來解決的問題。
library(likert)
library(plyr)
df <- data.frame(v1=c(1, 0, 1, 0, 1, 1, 0, 1),
v2=c(1, NA, 1, 0, 1, 1, 0, 1),
grp=c("a", "b", "a", NA, "a", "b", "a", "b"))
df[,1:2] <- lapply(df[,1:2],
factor,
levels=c(0,1),
labels=c("incorrect", "correct"))
df$grp <- factor(df$grp,
levels=c("a", "b"),
labels=c("a", "b"))
dfLikert <- likert(df[,1:2], grouping=df$grp)
summary(dfLikert)
plot(dfLikert, low.color="blue", high.color="green",
neutral.color="grey90", text.size=1.75) +
theme(axis.text.y=element_text(colour="darkgrey", size=10),
strip.text=element_text(colour="black", size=10))
這是直接原因的例子; '用(faceLikertG,results [results $ Group ==「boys」,])''。數據有2行,但有4行。 – cuttlefish44
謝謝@ Hack-R。我添加了一個新的例子。 –
@EricGreen謝謝,這有很大的幫助。由於某種原因,昨天晚上當我將NA轉換爲水平時,它仍然不起作用,但現在我可以看到你在說什麼 –