错误:stat_smooth需要以下缺失的美感:定义x和y时,x,y enen

时间:2019-06-27 07:14:37

标签: r ggplot2

我有一个简短示例,说明了我从csv文件读取的数据帧:

   entry    Number of sales     Median revenue
1: DN1_01   345                 1556
2: DN1_02   478                 2424
3: DN1_03   111                 450
4: DN1_04   595                 3265
5: DN1_05   446                 162

,我想用ggplot2绘制它。我运行以下脚本:

Figure_8 <- ggplot(figure8_df, aes(x = figure8_df$'number of sales', 
y= figure8_df$'median revenue')) +
geom_point(col = "darkmagenta", shape = 18) + ggtitle("Number of sales 
VS Median revenue") + 
xlab("Number of sales") + ylab("Median revenue") + geom_smooth(method = 'lm') +
theme(plot.title = element_text(hjust = 0.5, color="orange", size=14, face="bold.italic"),
    axis.title.x = element_text(color="#993333", size=10, face = "bold"),
    axis.title.y = element_text(color="#993333", size=10,face = "bold")) +
scale_y_continuous(breaks = pretty(figure8_df$'median revenue', n = 20))

并收到错误:

Error: stat_smooth requires the following missing aesthetics: x, y

但是我不明白这是什么问题。我在aes x和y中定义了,为什么我会收到此消息?

0 个答案:

没有答案