R/nested_data_matrix.R
nested_data.Rd
Prepare a parameter-long data frame for statistical analysis
nested_data(
.data,
qualifiers = NULL,
key = NULL,
value,
fill = NA,
select_if = ~TRUE,
filter_all = any_vars(TRUE),
trans = identity,
groups = NULL
)
unnested_data(.data, ...)
Data in parameter-long form
Columns that add context to observations (e.g., depth, zone, core)
The column name that contains the column names of the data matrix
The column name that contains the values
If a key/value combination doesn't exist in the input, this value will be assigned in the data matrix. Generally, using NA for geochemical data and 0 for relative abundance data is advised.
Use ~TRUE
to keep all columns; use ~all(is.finite(.))
to keep columns
with all finite values. See select_if.
Use any_vars(TRUE)
to keep all observations; use all_vars(is.finite(.))
to
keep only observations with finite (non-missing) values. See filter_all.
A function that will be applied to all columns, column-wise. Use identity to perform no transformation, use scale to scale each column to a mean of zero and variance of 1. See mutate_all.
Use group_by or this argument to group by one or more columns (e.g., core or lake)
One or more columns to unnest.
A nested data matrix, which is composed of a tibble::tibble()
with tibble list-columns data
, discarded_rows
, discarded_columns
, and
qualifiers
.
nested_data(
alta_lake_geochem,
qualifiers = c(age, depth, zone),
key = param,
value = value,
trans = scale
)
#> # A tibble: 1 × 4
#> discarded_columns discarded_rows qualifiers data
#> * <list> <list> <list> <list>
#> 1 <tibble [32 × 0]> <tibble [0 × 9]> <tibble [32 × 4]> <tibble [32 × 6]>