R 类型为'的对象;关闭';不可再附加[GGplot2,闪亮]
我正在使用shiny创建一个简单的应用程序 用户界面 和server.R(需要的数据集位于) 每当我运行与普通R脚本相同的服务器脚本时,一切都正常工作,但在Shining中使用相同的代码段会导致上述错误R 类型为'的对象;关闭';不可再附加[GGplot2,闪亮],r,ggplot2,shiny,R,Ggplot2,Shiny,我正在使用shiny创建一个简单的应用程序 用户界面 和server.R(需要的数据集位于) 每当我运行与普通R脚本相同的服务器脚本时,一切都正常工作,但在Shining中使用相同的代码段会导致上述错误 注意:我在链接中提到了相同的问题,但没有任何成功您想从aes调用中删除df$: p <- ggplot(df,aes(timestamp,power))+theme_bw() +geom_point() p然后尝试更改“p谢谢,它起作用了。我不知道为什么相同的代码在独立的R脚本中工作,但
注意:我在链接中提到了相同的问题,但没有任何成功您想从
aes
调用中删除df$
:
p <- ggplot(df,aes(timestamp,power))+theme_bw() +geom_point()
p然后尝试更改“p谢谢,它起作用了。我不知道为什么相同的代码在独立的R脚本中工作,但在shiny中失败。真的,疯狂。请将您的评论作为答案。这与ggplot
library(shiny)
library(ggplot2)
df <- readRDS("dataframe-path")
shinyServer(
function(input, output) {
output$plt <- renderPlot({
df$timestamp <- as.Date(df$timestamp)
p <- ggplot(df,aes(df$timestamp,df$power))+theme_bw() +geom_point()
print(p)
})
})
Error in df$timestamp : object of type 'closure' is not subsettable
p <- ggplot(df,aes(timestamp,power))+theme_bw() +geom_point()