A function that imports widemeasures in files into the R environment
Usage
read_wides(
files,
filetype = NULL,
startrow = NULL,
endrow = NULL,
startcol = NULL,
endcol = NULL,
header = TRUE,
sheet = NULL,
run_names = NULL,
run_names_header = "file",
run_names_dot = FALSE,
run_names_path = TRUE,
run_names_ext = FALSE,
metadata = NULL,
na.strings = c("NA", ""),
extension,
names_to_col,
...
)Arguments
- files
A
vectorof filepaths (relative to current working directory) where each one is a widemeasures set of data- 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,
read_wideswill infer filetype(s) from the extension(s) infiles. When extension is not "csv", "xls", or "xlsx", will use "table".- startrow, endrow, startcol, endcol
(optional) the rows and columns where the data are located in
files.Can be a
vectororlistthe same length asfiles, or a single value that applies to allfiles. Values can benumericor astringthat will be automatically converted tonumericby from_excel.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).
- header
logicalfor whether there is a header in the data. IfFALSEcolumns are simply numbered. IfTRUE, the first row of the data (startrowif specified) is used as the column names- 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 sheet
- run_names
Names to give the widemeasures read in. By default uses the file names if not specified
- run_names_header
Should the run names (provided in
run_namesor inferred fromfiles) be added as a column to the widemeasures? Ifrun_names_headerisNULL, they will not be. Ifrun_names_headeris astring, thatstringwill be the column header for the column where the names will be stored- run_names_dot
If
run_namesare inferred from filenames, should the leading './' (if any) be retained- run_names_path
If
run_namesare inferred from filenames, should the path (if any) be retained- run_names_ext
If
run_namesare inferred from filenames, should the file extension (if any) be retained- metadata
(optional) non-spectrophotometric data that should be associated with each read widemeasures. A named
listwhere each item in thelistis either: avectorof length 2, or alistcontaining twovectors.In the former case, each
vectorshould provide the row and column where the metadata is located in all of the blockmeasures input files.In the latter case, the first
vectorshould provide the rows where the metadata is located in each of the corresponding input files, and the secondvectorshould provide the columns where the metadata is located in each of the corresponding input files. (This case is typically used when reading multiple blocks from a single file.)- na.strings
A
charactervectorofstrings which are to be interpreted asNAvalues by read.csv, read_xls, read_xlsx, or read.table- extension
Deprecated, use
filetypeinstead- names_to_col
Deprecated, use
run_names_headerinstead- ...
Other arguments passed to read.csv, read_xls, read_xlsx, or read.table