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. Please make sure to call lpjmlkit::as_tibble() explicitly when also using the tidyverse packages tibble or dplyr.

# S3 method for LPJmLData
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

if (FALSE) {

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

}