readData: Read Data from Various File Types

View source: R/readData.R

readDataR Documentation

Read Data from Various File Types

Description

This function reads data from various file types such as CSV, DTA (Stata), REC (EpiInfo), RDA/RDATA, RDS, and Excel files. It provides options to factorize, convert column names to lowercase, and add labels to the data. If no filename is provided, a file dialog will be opened for the user to select a file.

Usage

readData(
  filename = "",
  factorise = FALSE,
  lowercase = FALSE,
  label = NULL,
  sheet = NULL,
  verbose = TRUE,
  ...
)

Arguments

filename

String specifying the path of the file to read. If empty, opens a file dialog.

factorise

Logical, if TRUE factorizes the data.

lowercase

Logical, if TRUE converts column names to lowercase.

label

Optional label to add to the data.

sheet

Sheet name or index for Excel files (If reading an Excel file)

verbose

Logical, if TRUE prints details about the loaded file.

...

Additional arguments passed to the underlying read functions like encoding="latin1".

Value

Returns a data frame of the loaded file, or an error if the file format is not supported or the file does not exist.

Examples

readData("flucases.csv")



Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.