Skip to contents

Creates an R expression that reads one or more files using standard R packages (readr, readxl, arrow, rio). This is a pure function with no Shiny dependencies, making it easily testable.

Usage

read_expr(
  paths,
  file_type = c("csv", "excel", "arrow", "other"),
  combine = c("first", "rbind", "cbind", "auto"),
  ...
)

Arguments

paths

Character vector of file paths to read

file_type

Character. Type of file: "csv", "excel", "arrow", or "other"

combine

Character. For multiple files: "first" (use first only), "rbind" (row bind), "cbind" (column bind), or "auto" (try rbind, fallback to first)

...

Additional parameters passed to the reader function. Common parameters:

  • For CSV: sep, col_names, skip, n_max, quote, encoding

  • For Excel: sheet, range, col_names, skip, n_max

Value

A language object (expression) that can be evaluated to read the file(s)

Examples

if (FALSE) { # \dontrun{
# Single CSV file
expr <- read_expr("data.csv", "csv", sep = ",", col_names = TRUE)
data <- eval(expr)

# Multiple CSV files with rbind
expr <- read_expr(
  c("data1.csv", "data2.csv"),
  "csv",
  combine = "rbind",
  sep = ","
)
data <- eval(expr)
} # }