我怎样才能使反应函数全局化?

时间:2017-04-26 15:38:41

标签: shiny rstudio

在下面的代码中,我如何在otherfunction()中使用myData()对象,这是另一个写入服务器功能的函数。 Rightnow myData()是本地的吗?我怎样才能让它全球化?

library(shiny)
write.csv(data.frame(a = 1:10, b = letters[1:10]), 'test.csv')
runApp(list(ui = fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv'))
),
mainPanel(
tableOutput('contents')
)
)
)
, 
shinyServer (function(input, output, session){
myData <- reactive({
inFile <- input$file1
if (is.null(inFile)) return(NULL)
data <- read.csv(inFile$datapath, header = TRUE)
data
})
output$contents <- renderTable({
myData()
})

theotherfunction=theotherfunction(input,output,session)

}
)
)
)

0 个答案:

没有答案