我刚接触过光泽,无法一次选择多个文件。我只是想知道是否有一种方法可以编辑我的代码来做到这一点。
rm(list = ls())
library(shiny)
ui = fluidPage(
sidebarPanel(
fileInput('file1', 'Choose file to upload',accept = c('text/csv','text/comma-separated-values','text/tab-separated-values','text/plain','.csv')),
checkboxInput('header', 'Header', TRUE),
tags$hr(),
actionButton("Load", "Load the File"),width = 3),
mainPanel(mainPanel(plotOutput("plot2"))))
library(ggplot2)
server = function(input, output) {
dat <- reactive({
if(input$Load == 0){return()}
inFile <- input$file1
if (is.null(inFile)){return(NULL)}
isolate({
input$Load
my_data <- read.csv(inFile$datapath, header = input$header, stringsAsFactors =FALSE, skip = 1)
colnames(my_data) <-c("wavelength","transmission")
names(my_data) <- c("wavelength", "transmission")
my_data$transmission <- (gsub(";","", my_data$transmission))
my_data$transmission <- as.numeric(gsub("-","", my_data$transmission))
})
my_data
})
output$plot2 <- renderPlot({ggplot(dat(),aes(x=wavelength,y=transmission))+geom_point(colour='red')},height = 400,width = 600)
}