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

Change legend values #110

Open
jamesquinlan opened this issue Jan 20, 2020 · 2 comments
Open

Change legend values #110

jamesquinlan opened this issue Jan 20, 2020 · 2 comments

Comments

@jamesquinlan
Copy link

jamesquinlan commented Jan 20, 2020

How, if possible, can I change the legend values of the Likert plot. In particular, my data has values 1, 2, 3, 4, 5 for SD, D, N, A, SA. Currently I run

# Read the data
survey=read.csv(thedata)

# Select which variables to compare
query=survey[,c(1,2, 3, 4, 6, 7, 8, 9, 10)]

results=likert(Items, grouping = query$Group)

plot(results, type="bar")

The legend at the bottom has "Response 1 2 3 4 5" with color squares. I want those color squares to correspond to "SD", "D", "N", "A", "SA" instead of 1-5.

Thanks in advance.

@jbryer
Copy link
Owner

jbryer commented Jan 21, 2020 via email

@jamesquinlan
Copy link
Author

Thanks, this worked:

library(likert) 

# Read the data
survey=read.csv(thedata)

# Convert integer data to factor for analysis
survey = survey %>% mutate_if(is.integer, as.factor)

# Set Labels
scale =c("Strongly Disagree", "Disagree", "Neutral","Agree","Strongly Agree") 

# Obtain Results (per group)
survey[,c(2:13)] =  lapply(survey[,c(2:13)], factor, levels=1:5, labels=scale)

# Select which variables to compare
query=survey[,c(1,2, 3, 4, 6, 7, 8, 9, 10)]

results=likert(Items, grouping = query$Group)
plot(results, type="bar")

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