table output from r to html -


app_test.r

 library(shiny)  ui <- fluidpage(      includehtml("www/index.html")   )   server <- function(input, output, session) {       data <- reactive({           f1<-paste(read.csv(input$file))           return(f1)       })       output$text <- rendertable({           x=data()       })     }     shinyapp(ui, server) 

index.html

<!doctype html>     <html>        <head>            <title>samp r html</title>        </head>    <body>        <form>            choose file:<input type="file" name="file" id="file" />        </form>        <p id="text" class="shiny-html-output" ></p>    </body>    </html> 

these 2 r , html files. want display csv file table uploaded user. iam getting error:'file' must character string or connection

do need use html template? there example in shiny gallery http://shiny.rstudio.com/gallery/file-upload.html.

additionally here's simple app should started.

library(shiny)  ui <- bootstrappage(   tags$div(style="margin:5% 5%",            fluidrow(              column(4,                     inputpanel(                       fileinput('csv_files', 'upload csv file:',                                 accept =                                    c('text/csv',                                      'text/comma-separated-values,text/plain',                                      '.csv')),                       checkboxinput('header', 'file has column names in first row', true),                       checkboxinput('rownames', 'include row names?', false),                       selectinput('sep', 'separator',                                    choices = list(                                     comma = ',',                                      semicolon = ';',                                      tab = "\\t")                       ),                       selectinput('quote', 'quote-type',                                    choices = list(                                     none = '',                                      double = '"',                                     single = "'"),                                   selected = '"')                     )              ),              column(8,                     tableoutput('uploaded_data')              )            )   ))    server <- function(input, output, session) {      output$uploaded_data <- rendertable({       raw_file <- input$csv_files      if(!is.null(raw_file)){         tbl <- read.csv(raw_file$datapath,                        header = input$header,                        sep = input$sep,                         quote = input$quote,                        stringsasfactors = false)        if(!input$rownames & colnames(tbl)[[1]] == "x"){          tbl[['x']] <- null        }        return(tbl)      }    }) }  shinyapp(ui = ui, server = server) 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -