loadAdatsAsList {SomaDataIO} | R Documentation |
Load ADAT files as a list
Description
Load a series of ADATs and return a list of soma_adat
objects, one for each ADAT file.
collapseAdats()
concatenates a list of ADATs from loadAdatsAsList()
,
while maintaining the relevant attribute entries (mainly the HEADER
element). This makes writing out the final object possible without the
loss of HEADER
information.
Usage
loadAdatsAsList(files, collapse = FALSE, verbose = interactive(), ...)
collapseAdats(x)
Arguments
files |
A character string of files to load. |
collapse |
Logical. Should the resulting list of ADATs be collapsed into a single ADAT object? |
verbose |
Logical. Should the function call be run in verbose mode. |
... |
Additional arguments passed to |
x |
A list of |
Details
- Note 1:
The default behavior is to "vertically bind" (
rbind()
) on the intersect of the column variables, with unique columns silently dropped.- Note 2:
If "vertically binding" on the column union is desired, use
bind_rows()
, however this results inNAs
in non-intersecting columns. For many files with little variable intersection, a sparse RFU-matrix will result (and will likely break ADAT attributes):adats <- loadAdatsAsList(files) union_adat <- dplyr::bind_rows(adats, .id = "SourceFile")
Value
A list of ADATs named by files
, each a soma_adat
object
corresponding to an individual file in files
. For collapseAdats()
,
a single, collapsed soma_adat
object.
Author(s)
Stu Field
See Also
Other IO:
parseHeader()
,
read_adat()
,
soma_adat
,
write_adat()
Examples
# only 1 file in directory
dir(system.file("extdata", package = "SomaDataIO"))
files <- system.file("extdata", package = "SomaDataIO") |>
dir(pattern = "[.]adat$", full.names = TRUE) |> rev()
adats <- loadAdatsAsList(files)
class(adats)
# collapse into 1 ADAT
collapsed <- collapseAdats(adats)
class(collapsed)
# Alternatively use `collapse = TRUE`
loadAdatsAsList(files, collapse = TRUE)