r - 如何将多个文件上传到R中的单个变量
问题描述
所以我有以下代码。有用。事情是我希望能够读取多个文件以对整个部分而不是 1 个文档进行分析。
应用功能的简短说明:
- 提供文字云
- 提供 Wordcorrelation (input$v)
- 情绪分析
- 最常用的词
服务器代码:
server <- function(input, output) {
output$plot <- renderPlot({
file1 <- input$file1
file2 <- input$file2
if (is.null(file1) && is.null(file2))
return(NULL)
if (!is.null(file1)) {
in2 <- pdf_text(file1$datapath)
}
if (!is.null(file2)) {
in2 <- readLines(file2$datapath)
}
界面代码
ui <- shinyUI(fluidPage(
titlePanel("Textmining Tool v0.1"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose PDF',
accept = c('text/pdf',
'.pdf')),
fileInput(
'file2',
'Choose TXT,CSV', multiple = T,
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
fileInput(
'pos',
'Choose pos',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
fileInput(
'neg',
'Choose neg',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
sliderInput(
"freq",
"Minimum Frequency:",
min = 1,
max = 50,
value = 15
),
sliderInput(
"max",
"Maximum Number of Words:",
min = 1,
max = 300,
value = 100
),
textInput("v", "Input correlation word", "")
),
mainPanel(
tabsetPanel(
type = "pills",
tabPanel("Wordcloud", plotOutput("plot")),
tabPanel("Wordcorrelation",DT::dataTableOutput("table")),
tabPanel("Sentimentanalysys", textOutput("sent")),
tabPanel("Most Frequent", DT::dataTableOutput("2"))
)
)
)
))
所以我感兴趣的是:如何将多个文件上传转换为单个文件变量,如“in2”。
提前致谢:)
解决方案
推荐阅读
- javascript - React:从 datalist 选项 onchange 获取数据属性
- c++ - 由于制表顺序,鼠标光标总是得到错误的 hwnd - MFC 应用程序
- css - 为不同的断点设置元素的大小
- realm - kerberos 配置具有多个域的单个 kdc
- python - 应用“setattr”后如何捕获原始函数的参数?
- html - 对 css 和 html 没有响应
- c# - 有没有一种方法可以多次运行一个方法,每次运行前增加时间?
- django - 我可以将 UserCreationFrom() html 的语言更改为西班牙语吗?
- javascript - 处理大数据时的 json.parse 函数
- excel - 如何使用包含分号的密码连接到 Oracle