1

I'm new to R and having next to nothing experience with it I'm struggling with what may be a pretty easy problem. I have a dataset of acceptability judgments provided by a group of 30 participants on 7 different verbs. I need to plot the verbs on the x-axis and the scores on the y-axis, so every single verb must have 30 data points.

I've tried to change a sample code which seemed to be close to what I was intending to do:

library(ggplot2)
data <- data.frame(y=abs(rnorm(16)), x=rep(c(0,100,200,300,400,500,600,700), each=2)) 
ggplot(data, aes(x, y, group=x)) + 
geom_boxplot(fill="green") +
xlab("x-axis") +
ylab("y-axis") +
ggtitle("Continuous Box plot ")

I obviously changed the random dataset part inserting my own data:

data_frame<-data.frame(
arrivare=9,8,9,9,9,9,9,9,9,9,9,9,7,9,9,9,9,9,9,9,9,9,9,9,5,9,9,9,9,8,9,
tornare=9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,8,8,
cambiare=9,8,9,9,9,9,9,8,9,9,9,9,9,8,9,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,8,
continuare=8,8,6,9,8,5,2,7,7,9,1,2,7,8,1,9,9,9,8,9,6,9,1,6,9,1,8,9,8,9,
vivere=9,3,7,1,9,9,2,8,5,6,3,2,9,6,9,2,9,9,5,1,9,1,9,1,1,1,1,9,9,8,7,
abitare=1,1,1,1,1,7,1,1,2,7,1,2,3,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,1,1,3,
suonare=7,1,8,1,7,7,1,9,8,8,1,1,9,6,1,9,1,9,3,3,2,9,1,7,5,1,9,9,8,9)

But I definitely got this part wrong: output

Do you have any suggestions on how to solve this issue?

Thank you!

0

1 Answer 1

0

I guess you can simply run boxplot

boxplot(df)

enter image description here

or fancier with ggplot

df %>%
  pivot_longer(everything()) %>%
  ggplot(aes(x = factor(name, levels = unique(name)), y = value)) +
  geom_boxplot(fill = "green") +
  xlab("x-axis") +
  ylab("y-axis") +
  ggtitle("Continuous Box plot ")

enter image description here

data

df <- data.frame(
  arrivare = c(9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 9, 9, 9, 9, 8, 9),
  tornare = c(9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8),
  cambiare = c(9, 8, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 8, 9, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8),
  continuare = c(8, 8, 6, 9, 8, 5, 2, 7, 7, 9, 1, 2, 7, 8, 1, 9, 9, 9, 8, 9, 6, 9, 1, 6, 9, 1, 8, 9, 8, 9, 9),
  vivere = c(9, 3, 7, 1, 9, 9, 2, 8, 5, 6, 3, 2, 9, 6, 9, 2, 9, 9, 5, 1, 9, 1, 9, 1, 1, 1, 1, 9, 9, 8, 7),
  abitare = c(1, 1, 1, 1, 1, 7, 1, 1, 2, 7, 1, 2, 3, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3),
  suonare = c(7, 1, 8, 1, 7, 7, 1, 9, 8, 8, 1, 1, 9, 6, 1, 9, 1, 9, 3, 3, 2, 9, 1, 7, 5, 1, 9, 9, 8, 9, 9)
)
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you @thomas! It was easier than I thought
Thanks @ThomasIsCoding, I guess I like better the second one. By the way, is it possible to maintain the original order of the verbs as they listed in the data frame, instead of the alphabetical order?
@DalerFergani you can use factor, see my update

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.