read_tidys {gcplyr} | R Documentation |
Read tidy-shaped files
Description
A function that imports tidy-shaped files into R. Largely acts as a wrapper for read.csv, read_xls, read_xls, or read_xlsx, but can handle multiple files at once and has additional options for taking subsets of rows/columns rather than the entire file and for adding filename or run names as an added column in the output.
Usage
read_tidys(
files,
filetype = NULL,
startrow = NULL,
endrow = NULL,
startcol = NULL,
endcol = NULL,
sheet = NULL,
run_names = NULL,
run_names_header = NULL,
run_names_dot = FALSE,
run_names_path = TRUE,
run_names_ext = FALSE,
na.strings = c("NA", ""),
extension,
names_to_col,
...
)
Arguments
files |
A vector of filepaths (relative to current working directory) where each one is a tidy-shaped data file |
filetype |
(optional) the type(s) of the files. Options include: "csv", "xls", or "xlsx". "tbl" or "table" to use read.table to read the file, "csv2" to use read.csv2, "delim" to use read.delim, or "delim2" to use read.delim2. If none provided, |
startrow , endrow , startcol , endcol |
(optional) the rows and columns where
the data are located in Can be a vector or list the same length as If not provided, data is presumed to begin on the first row and column of the file(s) and end on the last row and column of the file(s). |
sheet |
The sheet of the input files where data is located (if input files are .xls or .xlsx). If not specified defaults to the first |
run_names |
Names to give the tidy files read in. By default uses the
file names if not specified. These names may be added
to the resulting data frame depending on the value of
the |
run_names_header |
Should the run names (provided in If If If If |
run_names_dot |
If run_names are inferred from filenames, should the leading './' (if any) be retained |
run_names_path |
If run_names are inferred from filenames, should the path (if any) be retained |
run_names_ext |
If run_names are inferred from filenames, should the file extension (if any) be retained |
na.strings |
A character vector of strings which are to be interpreted
as |
extension |
Deprecated, use |
names_to_col |
Deprecated, use |
... |
Other arguments passed to read.csv, read_xls, read_xlsx, or read.table sheet |
Details
startrow
, endrow
, startcol
, endcol
,
sheet
and filetype
can either be a single value that
applies for all files or vectors or lists the same length as files
Note that the startrow is always assumed to be a header
Value
A dataframe containing a single tidy data.frame, or A list of tidy-shaped data.frames named by filename