readData: Read data in different formats ('xlsx', 'rds', 'csv', ...)

Description Usage Arguments Value Examples

View source: R/readData.R

Description

Shiny module for reading data into R. currently, the formats .csv, .sav, .xlsx, .rds and .Rdata are supported. the following formats will be mapped .txt -> .csv, .xls -> .xlsx.

Usage

1
2
3
4
readData(input, output, session, path, callback = function() { },
  symbol = NULL)

readDataUI(id)

Arguments

input, output, session

Standard module parameters.

path

A reactive value representing the path of the file to be read.

callback

A function that will be called in case of unsupported formats. Should have no arguments.

symbol

Optional: A symbol to use in the import code in place of the path. This is useful if the path has previously been saved as a variable.

id

The module identifier.

Value

A reactive string representing the code to read the dataset.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 

shinyApp(
  fluidPage(
    textInput("path", "choose a path", value = "mtcars.csv"),
    readDataUI("readDataId"),
    codeOutput("code")
  ),
  function(input, output, session){
    code <- callModule(readData, "readDataId", reactive(input$path))
    output$code <- renderCode({code()})
  }
)


## End(Not run)

statistikat/codeModules documentation built on Feb. 17, 2021, 11:42 a.m.