我想使用ShinyFiles从本地服务器目录上载文件。
要做到这一点,我已经做到了:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
shinyFilesButton('files', 'File select', 'Please select a file', FALSE),
verbatimTextOutput('filepaths')
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
roots = c(wd='/home/developer/')
reactivity <- reactive({
shinyFileChoose(input, 'files', roots=roots, filetypes=c('', 'RData'))
route<- parseFilePaths(roots, input$files)$datapath
load(route)
return(parseFilePaths(roots, input$files))
})
output$filepaths <- renderPrint({
reactivity()
})
}
# Run the application
shinyApp(ui = ui, server = server)
这仅在output $ filepath函数中起作用。如果要在其他函数中加载数据,则此函数不起作用,因为globalenvr为空。如何使用ShinyFiles将数据加载到globalEnvr?
谢谢!