我已经在ggploy中为组创建了一个框图.因此,我不得不将数据帧从宽格式reshape 为长格式.现在,我想要更改我的图表中各个绘图的标签或名称.我使用了函数xlim(labels= c("A", "B")
,它更改了标签,但给出了错误消息,并且不再计算/显示绘图.
data3 %>%
select(Treatment_A, Treatment_B) %>%
pivot_longer(cols = everything(), names_to = "Variable",values_to = "Value") %>%
ggplot(aes(x= Variable, y = Value, fill = Variable)) +
stat_boxplot(geom= "errorbar", width= 0.5) +
geom_boxplot(fill=c("skyblue2", "gold2"))+
labs(x="Treatment", y="Frequency (total)", title="Treatment comparison")+
theme_minimal()+
theme(axis.title.x = element_text(size =10))+
theme(axis.title.y = element_text(size =10))+
theme(plot.title=element_text(size = 16))+
theme(plot.title = element_text(hjust = 0.5))+
stat_summary(fun = mean, geom = "errorbar", aes(ymax = ..y.., ymin = ..y..),
width = .75,lwd = 0.7, linetype = "dashed", col = "red") +
xlim(labels= c("A", "B"))+ # <- This gives me the error
ylim(0,30)
警告消息:
1: Removed 2730 rows containing missing values (stat_boxplot).
2: Removed 2730 rows containing missing values (stat_boxplot).
3: Removed 2730 rows containing non-finite values (stat_summary).
4: In max(f) : no non-missing arguments to max; returning -Inf
5: Computation failed in `stat_summary()`:
argument must be coercible to non-negative integer
我对R还很陌生,需要为我的硕士论文提供图表,并感谢任何人的帮助.首先要感谢大家!