2

I am completely new to R and self taught - using for 5 days with help of YouTube videos.

I want to plot Likert survey responses but struggling to work out or find how.

There are eight questions with 561 responses on a 5 point scale. A ninth question has the survey participant respond with either yes or no.

Ideally, I want something like a goem_jitter showing the dispersal of responses and I can colour these dependent on the yes/no response to a 9th question.

The data set I've read in shows 9 obvs. of 562 variables.

I can recreate a plot for one participants response using this code.

opinionv3 %>%
  filter(question %in% c("q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8")) %>%
  ggplot(aes(x = question, y = p1)) +
  geom_jitter() +

I'd appreciate any advice.

Claire
  • 21
  • 2
  • Welcome to SO! Your fundamental problem is that your data are not [tidy](https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html). If your data frame had columns, say, for Respondant, Question and Response, it would be and you would find using the tidyverse (which, as its name suggests, is designed for tidy data!) much easier... – Limey Jun 16 '21 at 13:48
  • 1
    It will be extremely challenging to answer your question without at least a sample of your data. Please [edit] your question, copy the output of the `dput(head(opinionv3))` command from R and paste it into your question (preferred). Alternatively paste the tab delimited data from a spreadsheet program. Please see [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for more information. – Ian Campbell Jun 16 '21 at 14:19
  • I cleaned the data as suggested by @Limey and it is working. I'm still getting a handle on how R wants the data to be presented. Thank you. – Claire Jun 17 '21 at 16:18

1 Answers1

1

Reading between the lines, I think you may want something like this (to better show the data than geom_jitter would):

ggplot(opinionv3, aes(p1)) +
  geom_bar(stat='count') +
  facet_wrap(~question)

enter image description here

Or, if you want to show the points using jitter, perhaps combine this with a violin plot to show the distribution better:

ggplot(opinionv3, aes(question, p1)) +
  geom_violin() +
  geom_jitter(height = 0.1)

enter image description here

Some dummy data:

opinionv3 = data.frame(
  question = rep(paste0('q', 1:5), each=100),
  p1 = c(sample(1:5,100,T, prob=c(1,2,3,4,2)), 
         sample(1:5,100,T, prob=c(1,5,2,2,6)), 
         sample(1:5,100,T, prob=c(4,2,5,1,2)), 
         sample(1:5,100,T, prob=c(7,1,1,2,2)), 
         sample(1:5,100,T, prob=c(1,1,1,1,1)) 
  )
)
dww
  • 30,425
  • 5
  • 68
  • 111