データを一度作成して複数のプロットで再利用したいと思います。以下の例では、各プロットにデータを作成しますが、一度(x)を作成して各プロットでxを使用するにはどうすればよいですか?R Shinyサーバー内のデータを作成して再利用
ui <- shinyUI(
fluidPage(
sidebarLayout(
sidebarPanel(
numericInput(inputId = "mean", label = "Mean", value = 50)
),
mainPanel(
column(6,plotOutput(outputId = "hist1")
),
column(6,plotOutput(outputId = "hist2")
)
)
)
)
)
server <- function(input,output){
# I'd like to create the data just once here, and then reuse it in each plot
# x <- rnorm(100,input$mean,5)
output$hist1 <- renderPlot({
hist(rnorm(100,input$mean,5))
#hist(x)
})
output$hist2 <- renderPlot({
hist(rnorm(100,input$mean,5))
#hist(x)
})
}
runApp(list(ui = ui, server = server))
驚くばかりです。私はこのようなラッパーのようなものだと思っていたが、うまくいかなかった。多くのおかげで、Weihuang。 – Murray