A function that reads blocks into the R environment
Usage
read_blocks(
files,
filetype = NULL,
startrow = NULL,
endrow = NULL,
startcol = NULL,
endcol = NULL,
sheet = NULL,
metadata = NULL,
block_names = NULL,
block_names_header = "block_name",
block_names_dot = FALSE,
block_names_path = TRUE,
block_names_ext = FALSE,
header = NA,
sider = NA,
wellnames_numeric = FALSE,
na.strings = c("NA", ""),
extension,
block_name_header,
...
)Arguments
- files
A
vectorof filepaths relative to the current working directory where each filepath is a single plate read- 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_blockswill 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 measures 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).
- sheet
(optional) If data is in .xls or .xlsx files, which sheet it is located on. Defaults to the first sheet if not specified
- metadata
(optional) non-density data that should be associated with each read blockmeasures. 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.)- block_names
(optional)
vectorof names corresponding to each plate infiles. If not provided,block_namesare inferred from the filenames- block_names_header
The name of the metadata field containing the
block_names- block_names_dot
If
block_namesare inferred from filenames, should the leading './' (if any) be retained- block_names_path
If
block_namesare inferred from filenames, should the path (if any) be retained- block_names_ext
If
block_namesare inferred from filenames, should the file extension (if any) be retained- header
TRUE,FALSE, orNA, or avectorof such values, indicating whether the file(s) contains the column names as its first line. Ifheader = NAwill attempt to infer the presence of column names. Ifheader = FALSEor no column names are inferred whenheader = NA, column names will be generated automatically according towellnames_numeric- sider
TRUE,FALSE, orNA, or avectorof such values, indicating whether the file(s) contains the row names as its first column. Ifsider = NAwill attempt to infer the presence of row names. Ifsider = FALSEor no row names are inferred whensider = NA, row names will be generated automatically according towellnames_numeric- wellnames_numeric
If row names and column names are not provided in the input
data.frameas specified byheaderandsider, then names will be generated automatically according towellnames_numeric.If
wellnames_numericisTRUE, rows and columns will be numbered with "R" and "C" prefixes, respectively.If
wellnames_numericisFALSE, rows will be lettered A through Z, while columns will be numbered- na.strings
A
charactervectorofstrings which are to be interpreted asNAvalues by read.csv, read_xls, read_xlsx, or read.table- extension
Deprecated, use
filetypeinstead- block_name_header
Deprecated, use
block_names_headerinstead- ...
Other arguments passed to read.csv, read_xls, read_xlsx, or read.table
Value
A list where each entry is a list containing the block data.frame
followed by the block_names (or filenames, if block_names is not
provided) and any specified metadata.
Details
For metadata, read_blocks can handle an arbitrary number of additional
pieces of information to extract from each blockcurve file as metadata.
These pieces of information are specified as a named list of vectors
where each vector is the c(row, column) where the information is to be
pulled from in the input files.
This metadata is returned as the second list element of each
blockcurve, e.g.:
[[1]]
[1] data #1
[2] metadata
[2][1] name #1
[2][2] date-time #1
[2][3] temp #1
[[2]]
[1] data #2
[2] metadata
[2][1] name #2
[2][2] date-time #2
[2][3] temp #2
...
Calling uninterleave on the output of read_blocks works on block data
and the associated metadata because uninterleave operates on the highest
level entries of the list (the [[1]] [[2]] level items),
leaving the meta-data associated with the block data
trans_block_to_wide integrates this metadata into the
wide-shaped data.frame it produces