Итак, у меня есть следующий код. Оно работает. Дело в том, что я хотел бы иметь возможность читать несколько файлов для анализа целых разделов вместо одного документа.
Краткое описание функций приложения:
- Обеспечить Wordcloud
- Обеспечение корреляции слов (ввод $ v)
- Sentimentanalysis
- Самые частые слова
Код сервера:
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".
Заранее спасибо:)