Adding word sources

Case Studies: Building Web Applications with Shiny in R

Dean Attali

Shiny Consultant

Textarea inputs

  • data argument is text, use textInput()?

    chapter4_2_adding_word_sources.004.png

  • textAreaInput() similar, but provides multiple rows

    textAreaInput(inputId, label, value, rows, ...)
    

chapter4_2_adding_word_sources.005_b.png

Case Studies: Building Web Applications with Shiny in R

File inputs - UI

  • File inputs for uploading a (text) file to Shiny app
fileInput(inputId, label, ...)

chapter4_2_adding_word_sources.011.png

Case Studies: Building Web Applications with Shiny in R

File inputs - UI

chapter4_2_adding_word_sources.013.png

  • ?fileInput() for more options
Case Studies: Building Web Applications with Shiny in R

File inputs - server

  • After selecting a file, it gets uploaded and available to Shiny
  • Text inputs: input$<inputId> is text
  • Numeric inputs: input$<inputId> is a number
  • File inputs: input$<inputId> is NOT a file
Case Studies: Building Web Applications with Shiny in R

File inputs - server

  • File inputs: input$<inputId> is dataframe with 1 row per file

    • Variables: name, size, type, datapath
       name        size   type         datapath
    1  myfile.txt  6000   text/plain   C:/path/to/temporary/file/0.txt
    
    • datapath is most important: path of file
  • Read selected file:

      input$<inputId>$datapath
    
    • Text file:

      readLines(input$<inputId>$datapath)
      
Case Studies: Building Web Applications with Shiny in R

Let's practice!

Case Studies: Building Web Applications with Shiny in R

Preparing Video For Download...