如何从ShinyFiles上传RData
我想用ShinyFile上传RData文件,但我不知道怎么做 这对我不起作用:如何从ShinyFiles上传RData,r,shiny,R,Shiny,我想用ShinyFile上传RData文件,但我不知道怎么做 这对我不起作用: library(shiny) library(shinydashboard) library(shinyFiles) # Define UI for application that draws a histogram ui <- dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody( shinyFile
library(shiny)
library(shinydashboard)
library(shinyFiles)
# Define UI for application that draws a histogram
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
shinyFilesButton('files', label='File select', title='Please select a file', multiple=FALSE),
verbatimTextOutput("txt")
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
shinyFileChoose(input, 'files', root=c(root='/'), filetypes=c('', 'RData'))
output$txt <- renderPrint(
ls(parseFilePaths(roots= "/",selection = input$files))
)
}
# Run the application
shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(shinydashboard)
图书馆(shinyFiles)
#为绘制直方图的应用程序定义UI
ui我已经解决了它。这里是解决方案(希望对其他人有所帮助)
#为绘制直方图的应用程序定义UI
ui我用保存在本地机器硬盘上的文件尝试了这个。load
函数返回一条错误消息:警告:gzfile中出错:“description”参数无效
。我不知道是否可以对本地文件使用shinyFileChoose
。
files< - load(parseFilePaths(roots= "/",selection = input$files)$type)
# Define UI for application that draws a histogram
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'))
ruta <- parseFilePaths(roots, input$files)$datapath
load(ruta)
return(parseFilePaths(roots, input$files))
})
output$filepaths <- renderPrint({
reactivity()
})
}
# Run the application
shinyApp(ui = ui, server = server)