I'm working with the likert
package and I can produce grouped results. However, I can't figure out how can I work with two (or multiple) groups, i.e., grouping the results by two columns (sex and country)
In the wrong format, something like that
likert(ds[,3:7], grouping=ds[,1:2]) %>%
plot()
or:
likert(ds[,3:7], grouping=ds[,1]) %>%
plot() +
facet_wrap(~country)
The desired result can be this one
Or even better something like this one
Data and codes are below
ds <-structure(list(sex_female = structure(c(1L, 2L, 2L, 2L, 1L, 2L,
1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L,
2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L,
1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L), .Label = c("male",
"female"), class = "factor"), country = structure(c(2L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L,
2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L,
2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,
2L), .Label = c("br", "sp"), class = "factor"), eat1_c = structure(c(1L,
1L, 1L, 3L, 4L, 4L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 4L,
2L, 1L, 2L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 3L, 1L, 2L, 4L, 1L, 2L,
1L, 2L, 1L, 1L, 2L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 4L,
1L, 1L, 2L, 1L, 4L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 4L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
4L, 3L, 3L, 4L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 3L, 2L, 3L, 1L, 1L,
1L, 1L, 3L), .Label = c("0", "1", "2", "3"), class = "factor"),
eat2_c = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 4L, 1L, 1L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L,
NA, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, NA, 3L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
1L), .Label = c("0", "1", "2", "3"), class = "factor"), eat3_c = structure(c(2L,
3L, 3L, 4L, 4L, NA, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, NA, 2L,
1L, 1L, 3L, 2L, 3L, 1L, 1L, 3L, NA, 2L, 1L, 2L, 3L, 1L, 2L,
1L, 3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, 3L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 4L, 2L, 2L, 3L, 3L, 3L, 1L, 3L, 1L, 4L, 2L, 2L, 1L, 1L,
1L, 1L, 3L, 1L, 4L, 1L, 1L), .Label = c("0", "1", "2", "3"
), class = "factor")), row.names = c(NA, -100L), class = "data.frame")
library(likert)
likert(ds[,3:7], grouping=ds[,1]) %>%
plot()