0
我在R shiny(在Server.R中)使用以下代碼來獲取直方圖輸出。ggplot在Shiny中的直方圖問題
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
任何想法?如果沒有特殊原因,調用環境我不會做
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)
:
你需要什麼',environment = environment()'ggplot? – Batanichek