You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create some plots for a study, but in one of my surveys
all of the responses were 'neutral', 'agree' or 'strongly agree'. The
plot.percent feature doesn't seem to work if there aren't some
'disagree' or 'strongly disagree' responses (see example code). Is there
a fix for this?
Thanks!!
library(likert)
## Warning: package 'likert' was built under R version 3.5.3
## Loading required package: ggplot2
## Loading required package: xtable
library(plyr)
## Version 1: Doesn't plot ##
q1 = c(rep("Agree",2),rep("Strongly Agree",1))
q2 = c(rep("Neutral",1),rep("Agree",2))
q3 = c(rep("Neutral",1),rep("Agree",1),rep("Strongly Agree",1))
levels = c("Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree")
q1 = factor(q1, levels=levels)
q2 = factor(q2, levels=levels)
q3 = factor(q3, levels=levels)
data = data.frame(q1,q2,q3)
questions = c("Item 1", "Item 2", "Item 3")
names(data) = questions
l3 = likert(data)
plot(l3, plot.percents=T, plot.percent.high=F, plot.percent.low=F,
group.order = questions)
## Error: Aesthetics must be either length 1 or the same as the data (1): x, y, label, group
## Version 2: Does plot - only change was adding some 'disagree' responses ##
q1 = c(rep("Disagree",2),rep("Strongly Agree",1))
q2 = c(rep("Neutral",1),rep("Agree",2))
q3 = c(rep("Neutral",1),rep("Agree",1),rep("Strongly Agree",1))
levels = c("Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree")
q1 = factor(q1, levels=levels)
q2 = factor(q2, levels=levels)
q3 = factor(q3, levels=levels)
data = data.frame(q1,q2,q3)
questions = c("Item 1", "Item 2", "Item 3")
names(data) = questions
l3 = likert(data)
plot(l3, plot.percents=T, plot.percent.high=F, plot.percent.low=F,
group.order = questions)
The text was updated successfully, but these errors were encountered:
I found two possible workarounds for anyone in the same situation. They are far from perfect but worked for me.
You can either remove the centre: " include.center=F,"
or manually add 0.0000001 to one of the disagree responses in the likert results data.
I'm trying to create some plots for a study, but in one of my surveys
all of the responses were 'neutral', 'agree' or 'strongly agree'. The
plot.percent feature doesn't seem to work if there aren't some
'disagree' or 'strongly disagree' responses (see example code). Is there
a fix for this?
Thanks!!
The text was updated successfully, but these errors were encountered: