我正在尝试为我的绘图添加一些抖动,但我收到消息“错误:提供给连续比例的离散值”
我的代码看起来像这样(x 值“中位数”只是一个列标题)
pl1 <- ggscatter(
df1, x = "Median", y = "Yield",
color = "Year", add = "reg.line",
)+
xlim(0, 100)+
stat_regline_equation(
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~~"), color = Year)
)
pl1 <- pl1 + geom_point(aes(x ='Median', y = "Yield", colour = "NA"), alpha = 0.2)
pl1 <- pl1 + theme_classic()
pl1 <- pl1 + stat_summary(aes(x = "Median", y = "Yield"), fun=mean, color="blue")
pl1 <- pl1 + stat_summary(aes(x = "Median", y = "Yield"), fun=median, color="red")
pl1
pl2 <- ggscatter(
df1, x = "Median", y = "Yield",
color = "Year", add = "reg.line",
)+
xlim(0, 100)+
stat_regline_equation(
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~~"), color = Year)
)
pl2 <- pl2 + geom_jitter(aes(x ='Median', y = "Yield", colour = "Year"), alpha = 0.2)
pl2 <- pl2 + theme_classic()
pl2 <- pl2 + stat_summary(aes(x = "Median", y = "Yield"), fun=mean, color="blue")
pl2 <- pl2 + stat_summary(aes(x = "Median", y = "Yield"), fun=median, color="red")
pl2
class(df1$Yield)
class(df1$Median)
class(df1$Year)
install.packages("gridExtra", repos="http://R-Forge.R-project.org")
library(gridExtra)
grid.arrange(pl1,pl2, nrow=1)
我的值已更改为数字,所以我不确定是什么导致了问题。