R Shinny:如何上传头为T、分隔符为“的.csv文件&引用;默认情况下?

R Shinny:如何上传头为T、分隔符为“的.csv文件&引用;默认情况下?,r,csv,header,shiny,comma,R,Csv,Header,Shiny,Comma,我正在创建一个闪亮的应用程序,在其中我可以上传一个.csv文件,然后绘制数据 您可以下载 我是用下面的代码做的 library(shiny) library(ggplot2) ui <- fluidPage( titlePanel( tags$h1(tags$strong("Shiny app"))), tags$hr(), sidebarLayout( sidebarPanel( a("Example input file", href="https://www.dropbox.

我正在创建一个闪亮的应用程序,在其中我可以上传一个.csv文件,然后绘制数据

您可以下载

我是用下面的代码做的

library(shiny)
library(ggplot2)
ui <- fluidPage(
titlePanel(
tags$h1(tags$strong("Shiny app"))),
tags$hr(),
sidebarLayout(
sidebarPanel(
  a("Example input file",
  href="https://www.dropbox.com/s/4ye1ajss2ukn1e6/df_ts.csv?dl=0"),
  fileInput("file","Upload the file"), 
  h5(helpText("Select the read.table parameters below")), 
  checkboxInput(inputId = 'header', label = 'Header', value = TRUE),
  checkboxInput(inputId = "stringAsFactors", "stringAsFactors", FALSE), br(),
  radioButtons(inputId = 'sep', label = 'Separator', 
               choices = c(Comma=',' ,Semicolon=';'
                           ,Tab='\t', Space=''
               ), selected = ',')),
mainPanel(plotOutput("line") )))
server <- function(input,output){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()} 
read.csv(file1$datapath, header=input$header, sep=input$sep, quote=input$quote)
})
output$line <- renderPlot({
if (is.null(data())) { return() }
df <- data()
df$date <- as.Date(df$date, format="%d/%m/%Y") 
print(ggplot(data=df, aes(x=date, y=param1)) + geom_line())
})  
}
shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(GG2)

ui你可以这么做

read.csv(file1$datapath, header=TRUE, sep=',')

取消单选按钮,你可以这样做

read.csv(file1$datapath, header=TRUE, sep=',')

取消单选按钮

谢谢。我感谢你的帮助:)谢谢。我感谢你的帮助:)