【问题标题】:ggplot Histogram issues in ShinyShiny中的ggplot直方图问题
【发布时间】:2015-11-06 09:22:08
【问题描述】:

我在 R Shiny(在 Server.R 中)中使用以下代码来获取直方图输出。

 output$distPlot1 <- renderPlot({
       newdata <- subset(indooriv,seris_id=='2')
     ggplot(newdata, aes(x=isc),environment = environment()) + geom_histogram()

          })

但它一直给我以下错误。

Error in exists(name, envir = env, mode = mode) : 
  argument "env" is missing, with no default

有什么想法吗?

【问题讨论】:

  • 在ggplot中需要,environment = environment()吗?

标签: r shiny


【解决方案1】:

我无法重现您的错误,这对我来说很好:

library(shiny)
data(iris)

u.n <-  as.character(unique(iris$Species))
names(u.n) <- u.n

ui <- shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectInput('species','Species',choices =u.n)
    ),
    mainPanel(
      plotOutput('distPlot')  
    )
  )
))

server <- shinyServer(function(input,output,session){
  output$distPlot <- renderPlot({
    newdata <- subset(iris, iris$Species==input$species)
    ggplot(newdata, aes(x=Sepal.Width),environment = environment()) + geom_histogram()
  })
})

shinyApp(ui=ui,server = server)

如果没有特定理由调用环境,我不会这样做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-20
    • 2013-06-14
    • 1970-01-01
    • 2016-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多