У меня проблемы с попыткой создать сюжет Ликерта с двумя группами. Я провел опрос в двух сообществах. Теперь я хочу сравнить эти два сообщества. [Это мой фрейм данных] [1]. Пока что я загрузил лист с 3 колонками. Один столбец относится к местоположению (community1, community2), один включает ответы относительно econ_comm (1-6), а другой включает ответы относительно future_persp (1-6). Я создал объект likert и первую фигуру.
g_likert = likert(g[1:6])
plot(g_likert, ordered = FALSE, group.order = names(g[2:3]))
... и это сработало. Следующее - это то, что я получил до сих пор. [! [введите описание изображения здесь] [2]] [2]
Полагаю, сейчас важно сначала создать объект-объект: both<-g$Location
(работал)
Теперь я начинаются проблемы. Следующий код показывает мне ошибки:
both_likert_2 = likert(both[, c(1:3), drop=FALSE], grouping = both$location)
plot(both_likert_2, include.histogram = TRUE)
Ошибки:
Ошибка в [.data.frame (g, 1: 6): выбраны неопределенные столбцы
Ошибка в [.default (оба, c (1: 3), drop = FALSE): неверное число измерений - объект 'both_likert_2' не найден
[У меня сейчас также приложил скриншот моего R, просто чтобы убедиться.] [4] Я уже довольно долго борюсь и буду очень признателен за помощь. Лучший, Феликс
РЕДАКТИРОВАТЬ: [! [Это моя текущая ситуация в R] [5]] [5] Вот мой код для воспроизведения:
library(likert)
g<-read.csv2("C:/Users/felix/OneDrive/Documents/R/SurveyData2.csv", sep=";", dec=",", header=TRUE)
both<-g$Location
g <- within(g, {
gold_21cent <- factor(gold_21cent, levels=1:6, labels=c("Completely agree", "Agree", "Slightly agree", "Slightly disagree", "Disagree", "Completely disagree"))
future_persp <- factor(future_persp, levels=1:6, labels=c("Completely agree", "Agree", "Slightly agree", "Slightly disagree", "Disagree", "Completely disagree"))
jobs_comm <- factor(jobs_comm, levels=1:6, labels=c("Completely agree", "Agree", "Slightly agree", "Slightly disagree", "Disagree", "Completely disagree"))
} )
.........etc............
comm_likert = likert(g[,2:14], grouping=g[,1])
plot(comm_likert)
library(dplyr)
g %>%
rename (It offers important economic perspectives
= future_persp, It provides economic prosperity to the community
= econ_comm)%>% likert (группировка = расположение)%>% plot ()
РЕДАКТИРОВАТЬ: Использование dput (g)
structure(list(Location = structure(c(2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = c("Huan", "TP"), class = "factor"),
gold_21cent = structure(c(6L, 6L, 3L, 3L, 2L, 2L, 2L, 2L,
2L, 6L, 3L, 2L, 2L, 3L, 2L, 3L, 1L, 3L, 2L, NA, NA, 1L, 1L,
6L, 4L, 6L, 5L, 2L, 2L, 2L, 4L, 4L, 3L, 3L, 2L, 3L, 2L, 3L,
3L, NA, 2L, 3L, 2L, NA, 2L, 2L, 3L, 5L, 3L, 3L, 3L, 3L, 3L,
3L, 4L, 2L, 3L, 6L), .Label = c("Completely agree", "Agree",
"Slightly agree", "Slightly disagree", "Disagree", "Completely disagree"
), class = "factor"), life_quality = structure(c(3L, 3L,
6L, 6L, 5L, 5L, 6L, 5L, 6L, 3L, 3L, 6L, 4L, 6L, 6L, 6L, 6L,
6L, 6L, NA, NA, 3L, 5L, 6L, 2L, 6L, 5L, 3L, 2L, 3L, 1L, 1L,
2L, 2L, 3L, 1L, 3L, 2L, 3L, 1L, 3L, 3L, 2L, 3L, 1L, 2L, NA,
3L, 2L, 2L, 3L, 3L, 3L, 5L, 5L, 3L, 2L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), coexist_tradact = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 2L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 5L, 5L, 6L, 2L, 6L, 1L, 6L, 5L, 6L, 6L, 6L, 1L,
4L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 4L, 3L, 2L, 3L, 3L, 3L,
4L, 4L, 3L, 2L, 4L, 5L, 4L, 2L, 4L, 6L, 3L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), emigration_comm = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 5L, NA, 6L, 6L, 6L, 6L,
6L, 6L, 6L, NA, NA, 4L, 2L, 1L, 3L, 1L, 1L, 6L, 6L, 6L, 2L,
1L, 3L, 3L, 3L, 1L, 3L, 1L, 2L, 1L, 2L, 2L, 3L, 3L, 2L, 1L,
4L, 5L, 5L, 2L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), future_persp = structure(c(3L,
3L, 5L, 5L, 5L, 5L, 6L, 5L, 5L, 3L, 5L, 6L, 6L, 5L, 3L, 6L,
5L, 5L, 3L, 3L, 3L, 2L, 1L, 6L, 3L, 6L, 5L, 3L, 3L, 3L, 1L,
3L, 2L, 2L, 2L, 2L, 3L, 3L, 4L, 2L, 4L, 2L, 2L, 3L, 1L, 2L,
4L, 4L, 4L, 2L, 4L, 2L, 3L, 5L, 5L, 3L, 2L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), workers_comm = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 2L, 6L, 6L,
6L, 6L, 6L, 4L, 5L, NA, 1L, 6L, 1L, 6L, 5L, 6L, 6L, 6L, 1L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 1L, 4L, 3L, 4L, 5L, 3L, 3L, 4L, 4L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), work_project = structure(c(6L,
6L, 6L, 6L, 5L, 5L, 6L, 5L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 5L, 3L, 6L, 4L, 6L, 5L, 6L, 6L, 6L, 6L,
3L, 2L, 2L, 1L, 1L, 3L, 6L, 3L, 3L, 2L, 6L, 3L, 3L, 3L, 1L,
3L, 6L, 5L, 6L, 5L, 1L, 6L, 6L, 5L, 6L, 2L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), agree_comm = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 6L, 5L, 6L,
6L, 6L, 6L, 5L, 5L, 5L, 3L, 6L, 2L, 5L, 6L, 6L, 6L, 6L, 3L,
3L, 2L, 3L, 3L, 1L, 3L, 3L, 3L, 2L, 4L, 1L, 3L, NA, 3L, 2L,
3L, 3L, NA, 3L, 3L, 4L, 3L, 3L, 3L, 4L, 2L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), informed_deals = structure(c(4L,
4L, 1L, 1L, 5L, 6L, 5L, 5L, 5L, 6L, 4L, 5L, 5L, 6L, 4L, 6L,
5L, 6L, 4L, 6L, 6L, 6L, 1L, 6L, 3L, 6L, 1L, 2L, 2L, 2L, 4L,
2L, 3L, 3L, 2L, 1L, 5L, 6L, 5L, 2L, 3L, 5L, 3L, 3L, 4L, 4L,
2L, 4L, 4L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), fear_environ = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 5L, 1L,
1L, 1L, 1L, 6L, 6L, 1L, 2L, 1L, 4L, 1L, NA, 1L, 1L, 1L, 4L,
4L, 3L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 1L,
NA, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 2L, 2L, 3L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), water_quant = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 6L, 1L, 2L, 1L,
1L, 1L, 6L, 6L, 6L, 5L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
3L, 2L, 1L, 2L, 3L, 1L, 3L, 2L, 3L, 1L, 3L, 3L, NA, 2L, 1L,
5L, 1L, 1L, 2L, 4L, 1L, 3L, 1L, 2L, 3L, 3L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), support_govern = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 5L, 6L, 6L, 4L, 5L, 6L, 1L, 5L, 6L, 3L, 3L, 3L, 3L,
3L, 2L, 3L, 3L, 2L, 5L, 5L, 3L, 2L, 4L, 3L, 3L, NA, 1L, 1L,
2L, 6L, 3L, 3L, 3L, 4L, 4L, 6L, 4L, 4L, 3L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), proud_comm = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 6L, 1L, 1L, 1L,
3L, 1L, 2L, 1L, 1L, 2L, 5L, 2L, 1L, 2L, 2L, 2L, NA, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 3L, 1L, 2L, 1L, 3L, 2L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), econ_comm = structure(c(6L,
6L, 6L, 6L, 5L, 6L, 5L, 5L, 6L, 6L, 3L, 6L, 6L, 5L, 3L, 5L,
3L, 4L, 5L, 2L, 2L, 5L, 5L, 6L, 2L, 6L, 5L, 5L, 5L, 5L, 3L,
2L, 3L, 3L, 1L, 1L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 2L, 3L, 1L,
3L, 2L, 3L, 1L, 5L, 3L, 2L, 5L, 2L, 6L, 3L, 4L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), jobs_comm = structure(c(6L,
6L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 4L, 6L, 4L,
6L, 4L, 5L, 5L, 5L, 3L, 2L, 6L, 1L, 6L, 5L, 5L, 5L, 5L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L,
2L, 2L, 2L, 1L, 5L, 2L, 3L, 4L, 2L, 2L, 3L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), inequality_comm = structure(c(1L,
1L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 1L, 3L, 6L, 1L, 2L, 6L, 2L,
6L, 2L, 6L, NA, NA, 5L, 1L, 6L, 3L, 6L, 5L, 5L, 5L, 5L, 1L,
3L, 3L, 2L, 3L, 4L, 2L, 3L, 4L, 3L, 2L, 4L, 3L, 3L, 5L, 3L,
4L, 5L, 3L, 1L, 4L, 3L, 4L, 2L, 3L, NA, 3L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), exp_growth = structure(c(6L,
6L, 4L, 4L, 6L, 6L, 6L, 5L, 6L, 6L, 4L, 4L, 6L, 2L, 2L, 2L,
5L, 2L, 3L, NA, NA, 3L, 3L, 6L, 1L, 6L, 5L, 3L, 2L, 6L, 4L,
2L, 2L, 3L, 2L, 3L, 5L, 2L, 3L, 2L, 3L, 4L, 2L, 3L, 2L, 1L,
2L, 5L, 3L, 4L, 2L, 4L, 2L, 6L, 3L, 3L, 3L, 3L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), future_region = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
5L, 6L, 5L, 2L, 2L, 2L, 2L, 6L, 3L, 6L, 5L, 6L, 6L, 3L, 4L,
2L, 3L, 3L, 2L, 4L, 5L, 5L, 5L, 2L, 4L, 2L, 4L, 3L, 4L, 1L,
NA, 6L, 3L, 3L, 3L, 4L, 3L, 4L, 5L, 5L, 2L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), contamination_environ = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 6L, 1L, 6L, 1L,
6L, 1L, 1L, 6L, 6L, 6L, 4L, 1L, 4L, 6L, 1L, 1L, 1L, 1L, 4L,
1L, 2L, 1L, 3L, 3L, 1L, 2L, 1L, 3L, 3L, 5L, 2L, 2L, 1L, 1L,
NA, 1L, 1L, 1L, 1L, 5L, 2L, 1L, 3L, 2L, 3L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), conflicts_comm = structure(c(6L,
6L, 1L, 1L, 6L, 6L, 6L, 6L, 6L, 1L, 2L, 1L, 1L, 1L, 2L, 1L,
2L, 1L, 6L, 5L, 5L, 5L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 4L,
3L, 3L, 3L, 3L, 1L, 3L, 2L, 4L, 3L, 3L, 4L, 3L, NA, 4L, 2L,
3L, 2L, 3L, 3L, 5L, 4L, 4L, 1L, 3L, 5L, 3L, 4L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), infrastructure_comm = structure(c(6L,
6L, 6L, 6L, 6L, 6L, 6L, 5L, 6L, 6L, 4L, 6L, 5L, 6L, 5L, 6L,
5L, 6L, 3L, 3L, 3L, NA, 1L, 6L, 1L, 6L, 6L, 4L, 4L, 3L, 1L,
4L, 3L, NA, 3L, 1L, 5L, 6L, 2L, 3L, 3L, 4L, 3L, 2L, 1L, 2L,
2L, 4L, 2L, 3L, 6L, 4L, 3L, 3L, 3L, 3L, 2L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), included_mining = structure(c(1L,
1L, 1L, 1L, 5L, 6L, 6L, 6L, 6L, 6L, 3L, 6L, 6L, 6L, 5L, 6L,
6L, 6L, 3L, 5L, 5L, 6L, 3L, NA, 3L, NA, NA, 6L, 5L, 5L, 1L,
3L, 3L, 3L, 3L, 5L, 4L, 6L, 3L, 3L, 2L, 6L, 2L, NA, 2L, 3L,
2L, 5L, 5L, 3L, 5L, 3L, 3L, 2L, 4L, 5L, 3L, NA), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), investment_region = structure(c(1L,
1L, 3L, 3L, 6L, 6L, 6L, 5L, 6L, 1L, 2L, 1L, 6L, 2L, 4L, 1L,
2L, 2L, 3L, NA, NA, 4L, 1L, 5L, 3L, 5L, 5L, 1L, 2L, 2L, 4L,
2L, 2L, 2L, 4L, 1L, 2L, 3L, 3L, 2L, 3L, 1L, 3L, NA, 3L, 2L,
NA, 2L, 3L, 3L, 4L, 4L, 3L, 3L, 2L, 2L, 2L, 4L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor"), water_qual = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 6L, 5L, 5L, 5L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
4L, 3L, 1L, 2L, 3L, 1L, 3L, 2L, 3L, 1L, 3L, 3L, NA, 3L, 1L,
4L, 1L, 1L, 3L, 4L, 2L, 2L, 1L, 2L, 3L, 3L, 2L), .Label = c("Completely agree",
"Agree", "Slightly agree", "Slightly disagree", "Disagree",
"Completely disagree"), class = "factor")), row.names = c(NA,
-58L), класс = "data.frame")