admin管理员组文章数量:1390967
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:
Do you have any suggestions on how to solve this issue?
Thank you!
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:
Do you have any suggestions on how to solve this issue?
Thank you!
Share Improve this question edited Mar 14 at 11:10 dthorbur 1,1433 gold badges13 silver badges26 bronze badges asked Mar 14 at 10:55 Daler FerganiDaler Fergani 111 bronze badge 01 Answer
Reset to default 0I guess you can simply run boxplot
boxplot(df)
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 ")
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)
)
本文标签: datasetboxplot across multiple columns in RStack Overflow
版权声明:本文标题:dataset - boxplot across multiple columns in R - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744660904a2618240.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论