as_tibble: Coerce an LPJmLData object to a tibble

View source: R/LPJmLData_as.R

as_tibbleR Documentation

Coerce an LPJmLData object to a tibble

Description

Function to coerce (convert) an LPJmLData object into a tibble (modern data.frame). Read more about tibbles at https://r4ds.had.co.nz/tibbles.html.

Usage

as_tibble(x, subset = NULL, aggregate = NULL, value_name = "value", ...)

Arguments

x

LPJmLData object

subset

List of array dimension(s) as name/key and corresponding subset vector as value, e.g. list(cell = c(27411:27415)). More information at subset.LPJmLData().

aggregate

List of array dimension(s) as name/key and corresponding aggregation function as value, e.g. list(band = sum).

value_name

Name of value column in returned tibble. Defaults to "value".

...

Arguments passed to the aggregate function(s), e.g. na.rm = TRUE.

Value

a tibble with columns corresponding to dimension naming of the LPJmLData$data array and values in one value column.

Examples

## Not run: 

vegc <- read_io(filename = "./vegc.bin.json")

# Returns two-dimensional tibble representation of vegc$data.
as_tibble(vegc)
#   cell  time       band    value
#   <fct> <fct>      <fct>   <dbl>
# 1 0     1901-12-31 1     13627.
# 2 1     1901-12-31 1       120.
# 3 2     1901-12-31 1       133.
# 4 3     1901-12-31 1        97.4
# 5 4     1901-12-31 1        75.9
# 6 5     1901-12-31 1        11.1


## End(Not run)


lpjmlkit documentation built on March 31, 2023, 9:35 p.m.