0

我收到一个错误:
Cannot add ggproto objects together. Did you forget to add this object to a ggplot object? 当我进行以下映射时(特别是“平滑”):

plot.type <- switch(input$plot.type, 
                          "Boxplot"=geom_boxplot(aes(group=1)), 
                          "Histogram"=geom_histogram(alpha=0.5, position="identity"), 
                          "Density"=geom_density(alpha=0.75), 
                          "Bar"=geom_bar(position="dodge"), 
                          "Scatter"=geom_point(aes_string(x=plot.obj$group, 
                                                          y=plot.obj$variable)),
                          "Smooth"= geom_point(aes_string(x=plot.obj$group, 
                                                          y=plot.obj$variable)) + geom_smooth(aes(group=1)))  

本质上,我正在添加到这样定义的基本 ggplot 中,它来自我在闪亮服务器中创建的绘图对象。我在 data.frame 上尝试了以下代码,它运行良好。我将在下面包含该代码和所需的输出。
我会很感激任何关于我哪里出错的提示。通过查看具有相同错误的其他帖子,我怀疑这是由于我如何将数据作为绘图对象获取的。

data_1 <- read.csv("~/DATA/plot.csv")

p <- ggplot(data_1, aes(
                x=Number.of.trucks.arrived,
                y=Number.of.replenishment.orders.to.Pickface))
p <- p + geom_point() + geom_smooth()
p

样本输出

4

0 回答 0