r - 如何通过 Shiny 上传 www 文件夹中的文件
问题描述
我希望我的文件上传到 Shiny 的 www 文件夹中。我正在使用此代码上传,但它没有上传 www 文件夹中的文件。有谁知道我该怎么做?我的操作系统是 Windows。我正在使用这段代码:
这是“ui.R”:
fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
tags$hr(),
checkboxInput('header', 'Header', TRUE),
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
',')
),
mainPanel(
tableOutput('contents')
)
)
)
这是“server.R”:
# By default, the file size limit is 5MB. It can be changed by
# setting this option. Here we'll raise limit to 9MB.
options(shiny.maxRequestSize = 9*1024^2)
function(input, output) {
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header = input$header,
sep = input$sep, quote = input$quote)
})
}
解决方案
推荐阅读
- python - 计算一个字母在一个单词中出现的次数,并将它们按以下格式排列:
- kotlin - 如果项目 Reactor 中的其他 Mono 为空,则修改 Mono?
- php - 找不到类 'PHPMailer\\PHPMailer\\Exception'
- python - 将 Rijndael 加密从 python 2 转换为 3
- java - Mockito 测试 Rest 客户端
- html - HTML:单选按钮
- python - 错误:“python setup.py egg_info”失败,错误代码为 1
- r - r - 分割 beta 分布时,for 循环返回全零
- c# - 在C#中给定3x3矩阵的特征值查找特征向量的算法
- powershell - 通过 Powershell 将一行数据添加到 CSV 文件