sfn_metrics: Metrics summary function

Description Usage Arguments Value Period .funs Interval See Also Examples

View source: R/metrics.R

Description

Generate metrics from a site/s data for the period indicated

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sfn_metrics(
  sfn_data,
  period,
  .funs,
  solar,
  interval = c("general", "predawn", "midday", "night", "daylight"),
  int_start = NULL,
  int_end = NULL,
  ...
)

Arguments

sfn_data

sfn_data or sfn_data_multi object to obtain the metrics from

period

Time period to aggregate data by. See period section for an explanation about the periods ('1 day', '1 month', '1 year', ...)

.funs

List of function calls to summarise the data by, see .funs section for more details.

solar

Logical indicating if the solarTIMESTAMP must be used instead of the site local TIMESTAMP. Default to TRUE (use solarTIMESTAMP).

interval

Character vector indicating if the metrics must be filtered by an special hour interval. See Interval section in details.

int_start

Integer value indicating the starting hour of the special interval in 24h format. See Interval section in details.

int_end

Integer value indicating the ending hour of the special interval in 24h format. See Interval section in details.

...

optional arguments to pass to methods used (i.e. .collapse_timestamp or summarise funs extra arguments)

Value

For sfn_data objects, a list of tbl_df objects with the following structure:

For sfn_data_multi objects, a list of lists of tbl_df objects with the metrics for each site:

Period

period argument is used by internal function .collapse_timestamp and it can be stated in two ways:

.collapse_timestamp also accepts the side argument to collapse by the starting timestamp or the ending timestamp of each group. This can be supplied in the ... argument.

.funs

.funs argument uses the same method as the .funs argument in the summarise_all function of dplyr package. Basically it accepts a list of function calls generated by list(). If you want to pass on a custom function you can specify it here. See details in summarise_by_period for more complex summarising functions declaration.

Interval

Previously to the metrics summary, data can be filtered by an special interval (i.e. predawn or nightly). This filtering can be specified with the interval argument as this:

See Also

Other metrics: metrics

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
library(dplyr)

### general metrics
## sfn_data
data('ARG_TRE', package = 'sapfluxnetr')
ARG_TRE_metrics <- sfn_metrics(
  ARG_TRE,
  period = '7 days',
  .funs = list(~ mean(., na.rm = TRUE), ~ sd(., na.rm = TRUE), ~ n()),
  solar = FALSE,
  interval = 'general'
)

str(ARG_TRE_metrics)
ARG_TRE_metrics[['sapf']]
ARG_TRE_metrics[['env']]

## sfn_data_multi

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

multi_metrics <- sfn_metrics(
  multi_sfn,
  period = '7 days',
  .funs = list(~ mean(., na.rm = TRUE), ~ sd(., na.rm = TRUE), ~ n()),
  solar = FALSE,
  interval = 'general'
)

str(multi_metrics)

multi_metrics[['ARG_TRE']][['sapf']]


### midday metrics
ARG_TRE_midday <- sfn_metrics(
  ARG_TRE,
  period = '1 day',
  .funs = list(~ mean(., na.rm = TRUE), ~ sd(., na.rm = TRUE), ~ n()),
  solar = TRUE,
  interval = 'midday', int_start = 11, int_end = 13
)

str(ARG_TRE_midday)
ARG_TRE_midday[['sapf']]

sapfluxnetr documentation built on Aug. 28, 2020, 1:13 a.m.