Wie kann ich eine Datei und einen Pfad angeben, um eine Datei mit R-shiny und shinyFiles zu speichern?

Ich arbeite mit R (glänzend) und möchte einen Datenrahmen als Excel-Datei speichern. Zu diesem Zweck verwende ich das Paket "shinyFiles", damit der Benutzer angeben kann, wo die Excel-Datei gespeichert werden soll:

server.R library (shiny) library (shinyFiles)

shinyServer(function(input, output, session) {

## ShinyFiles : get the user favorite directory
volumes=c(home = '~/'),
shinyDirChoose(input, 'dir', roots=volumes, filetypes = c('','xlsx')),
output$dir.res <- renderPrint({parseDirPath(volumes, input$dir)}),

## Button to save the file
observeEvent(input$button.save, {

## A standard file name
A <- "name"
B <- "family
if( input$text == "File name..." ) outFile <- paste( A, "_", B, ".xlsx", sep="" )

## Append the path to the file name
outFile <- paste( parseDirPath(volumes, input$path.out), outFile, sep="/" )

## The data to be saved
x=seq(from=0,to=10,by=1)
d = data.frame( x )
write.xlsx( d, outFile )
}

und die ui.R

library(shiny)
library(shinyFiles)

shinyUI(fluidPage(sidebarLayout(

## Choose the output directory
shinyDirButton("dir", "Choose directory", "Upload"),
## Choose the output file name
textInput("text", label = "", value = "File name..."),
## Save the data
actionButton("button.save", "Save the file"),
## Give the path selected
verbatimTextOutput("dir.res")
)))

Trotz all der Beispiele für ähnliche Fragen, die ich 2 Stunden lang ausprobiert habe (schade ..) und für Hilfe dankbar sein werde

Antworten auf die Frage(2)

Ihre Antwort auf die Frage