这就是我要处理的数据
> Age_Time
# A tibble: 268 x 2
Age Time
<chr> <chr>
1 [18,24[ 1-5 hours
2 [10,18[ 1-5 hours
3 [18,24[ >10 hours
4 [18,24[ 5-10 hours
5 [18,24[ 5-10 hours
6 [24,34[ 1-5 hours
7 [18,24[ 5-10 hours
8 [18,24[ 5-10 hours
9 [24,34[ 0 hours
10 [18,24[ 5-10 hours
# ... with 258 more rows
> str(head(Age_Time))
tibble [6 x 2] (S3: tbl_df/tbl/data.frame)
$ Age : chr [1:6] "[18,24[" "[10,18[" "[18,24[" "[18,24[" ...
$ Time: chr [1:6] "1-5 hours" "1-5 hours" ">10 hours" "5-10 hours" ...我分别制作了5个酒壶,我想把它们放在同一个工作空间中,这样它们就一起显示了。
Age_time=Survey[3:4]
Time1=Age_time %>%
filter(Time=="0 hours")
b1 <- barplot(table(Time1$Age),col=colors,ylim=c(0,10),main = "No time spent on Social Media")
text(b1[,1],table(Time1$Age)-1,table(Time1$Age))
Time2=Age_time %>%
filter(Time== "<1 hours")
b2 <- barplot(table(Time2$Age),col=colors,ylim=c(0,20),main="Less than an hour spent on Social Media")
text(b2[,1],table(Time2$Age)-1,table(Time2$Age))
Time3=Age_time %>%
filter(Time =="1-5 hours")
b3 <- barplot(table(Time3$Age),col=colors,ylim=c(0,100),main="1 to 5 hours on Social Media")
text(b3[,1],table(Time3$Age)-1,table(Time3$Age))
Time4=Age_time %>%
filter(Time =="5-10 hours")
b4 <- barplot(table(Time4$Age),col=colors,ylim=c(0,90),main="5 to 10 hours on Social Media")
text(b4[,1],table(Time4$Age)-1,table(Time4$Age))
Time5=Age_time %>%
filter(Time ==">10 hours")
b5 <- barplot(table(Time5$Age),col=colors,ylim=c(0,40),main="More than 10 hours on Social Media")
text(b5[,1],table(Time5$Age)-1,table(Time5$Age))我不介意修改整个代码,例如,只要我最终得到了我想要的结果,它就是并行获得(而不是共享轴)的5位数。
发布于 2021-06-03 20:05:54
试着把它放在第一个barplot之前
par(mfrow=c(1,5))这将将所有5个barplot的并排放置在同一个绘图窗口中。
https://stackoverflow.com/questions/67827904
复制相似问题