我想将UI上用户上传的CSV文件中的数据复制到我系统上的另一个CSV文件中。应以完全相同的方式复制数据。该怎么办?
答案 0 :(得分:1)
server.R:
library(shiny)
library(DT)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
df_products_upload <- observeEvent(input$target_upload,{
inFile <- input$target_upload
if (is.null(inFile))
return(NULL)
file.copy(inFile$datapath, paste0(getwd(),"/data.csv"), overwrite = TRUE, recursive = FALSE,
copy.mode = TRUE, copy.date = FALSE)
})
}
)
ui.R
ui <- shinyUI(fluidPage(
fileInput('target_upload', 'Choose file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'.csv'
))
)
)
将文件复制到工作目录中的data.csv。希望这有帮助!