Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot percentages doesn't work without some "disagree" responses #103

Open
pmurray07 opened this issue May 30, 2019 · 2 comments
Open

Plot percentages doesn't work without some "disagree" responses #103

pmurray07 opened this issue May 30, 2019 · 2 comments

Comments

@pmurray07
Copy link

pmurray07 commented May 30, 2019

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)

@Badzo0
Copy link

Badzo0 commented May 3, 2022

Was a solution found for this? I have the same issue and cannot find a working solution.

@Badzo0
Copy link

Badzo0 commented May 3, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants