2

I have done many graphs for likert scale questionaries using large datasets in its original form (microdata). But this time I’m working with a small dataframe which summarizes the results of processing a large dataset. The problem happens when working with summary dataframe and with uneven categories (Eg:4). The problem does not occur when working with microdata it just happens when working with summarized. Example (using pisaitems dataframe):

rm(list=ls())
data("pisaitems")

cana1 <- likert(pisaitems[2:4])
plot(cana1)

ST24Q01 <- prop.table(table(pisaitems$ST24Q01))*100
ST24Q02 <- prop.table(table(pisaitems$ST24Q02))*100
ST24Q03 <- prop.table(table(pisaitems$ST24Q03))*100

df2 <- as.data.frame(t(cbind(ST24Q01,ST24Q02,ST24Q03)))
df2 <- tibble::rownames_to_column(df2, "row_names")
colnames(df2)[1] <- c("Item")

cana2 <- likert(summary = df2)
plot(cana2)

I get de following message:

Error in data.frame(Item = results[, 1], low = low, neutral = neutral,  : 
  object 'neutral' not found

As a clue, among many solutions that I've tried, I use the option "center", but it works just when using integer numbers and not when using "2.5" that will be the correct place to divide the 4 categories.

Could somebody help me to properly use likert R Package for summary dataframe intead of microdata with even number of categories?

1 Answers1

1

I suspect the error is caused by the loss of the 'items' variable in the summary dataframe (comprised of 66690 obs. of 3 variables in this case; i.e. the actual data). If you 'add in' the items (e.g. from cana1) you get the expected result:

#install.packages("likert")
library(likert)
#> Loading required package: ggplot2
#> Loading required package: xtable

data("pisaitems")

cana1 <- likert(pisaitems[2:4])
plot(cana1)

ST24Q01 <- prop.table(table(pisaitems$ST24Q01))*100
ST24Q02 <- prop.table(table(pisaitems$ST24Q02))*100
ST24Q03 <- prop.table(table(pisaitems$ST24Q03))*100

df2 <- as.data.frame(t(cbind(ST24Q01,ST24Q02,ST24Q03)))
df2 <- tibble::rownames_to_column(df2, "row_names")
colnames(df2)[1] <- c("Item")

cana2 <- likert(summary = df2)
cana2$items
#> NULL
plot(cana2)
#> Error in data.frame(Item = results[, 1], low = low, neutral = neutral, : object 'neutral' not found

cana2$items <- cana1$items
plot(cana2)

Created on 2022-10-26 by the reprex package (v2.0.1)

I believe you can build the likert plot using the summary data (e.g. this tutorial: https://rpubs.com/m_dev/likert_summary) but I think you need to include the 'raw' data in your df2 dataframe as well.

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46
  • Thanks Jared. I thought that at the beginning but when I realized that it works for uneven number of categories I think that, maybe, there is a way in which it should work for even as well. – Rodrigo Alberto Salas Portugue Oct 25 '22 at 22:45