metrics_tidyfier: Build a tidy data frame from the metrics results nested list

metrics_tidyfierR Documentation

Build a tidy data frame from the metrics results nested list

Description

Transform the nested list of metrics in a tidy tibble where each observation has its own row

Usage

metrics_tidyfier(
  metrics_res,
  metadata,
  interval = c("general", "predawn", "midday", "night", "daylight")
)

Arguments

metrics_res

Nested list containing the metrics results as obtained from metrics

metadata

List containing the metadata nested list, as obtained from read_sfn_metadata

interval

Interval to return, it depends on the metrics_res and can be "gen" for the general metrics, "md" for midday metrics, "pd" for predawn metrics, "night" for night metrics or "day" for diurnal metrics.

Value

a tibble with the following columns:

  • TIMESTAMP: POSIXct vector with the date-time of the observation

  • si_code: Character vector with the site codes

  • pl_code: Character vector with the plant codes

  • sapflow_*: Variables containing the different metrics for the sapflow measurements (i.e. sapflow_mean, sapflow_q_95)

  • ta_*; rh_*; vpd_*; ...: Variables containing the different metrics for environmental variables (i.e. ta_mean, ta_q_95)

  • pl_*: plant metadata variables (i.e. pl_sapw_area, pl_sens_meth)

  • si_*: site metadata variables (i.e. si_biome, si_contact_firstname)

  • st_*: stand metadata variables (i.e. st_aspect, st_lai)

  • sp_*: species metadata variables (i.e. sp_basal_area_perc)

  • env_*: environmental metadata variables (i.e. env_timezone)

Examples


# data
multi_sfn <- sfn_data_multi(ARG_TRE, ARG_MAZ, AUS_CAN_ST2_MIX)
data('sfn_metadata_ex', package = 'sapfluxnetr')

# metrics
multi_metrics <- daily_metrics(multi_sfn)

# tidyfing
multi_tidy <- metrics_tidyfier(
  multi_metrics, sfn_metadata_ex, interval = 'general'
)
multi_tidy

# A really easier way of doing the same
multi_tidy_easy <- daily_metrics(multi_sfn, tidy = TRUE, metadata = sfn_metadata_ex)



sapfluxnet/sapfluxnetr documentation built on Feb. 6, 2023, 10:37 p.m.