sfn_filter: Filter sfn_data by variable/s value

Description Usage Arguments Details Value Examples

View source: R/sfn_dplyr.R

Description

Port of filter for sfn_data and sfn_data_multi objects

Usage

1

Arguments

sfn_data

sfn_data or sfn_data_multi object to subset

...

expressions to pass to the filter function

solar

Logical indicating if solar timestamp must used to subset

Details

'sfn_filter' will remove the rows not matching the logical expression/s provided. So, it will remove cases and will create TIMESTAMP gaps, so its use is not recommended except in the case of filtering by TIMESTAMP (i.e. to set several sites (sfn_data_multi) in the same time frame). For other scenarios (removing extreme environmental conditions values or strange sapflow measures patterns) see sfn_mutate and sfn_mutate_at

Value

For sfn_data objects, a filtered sfn_data or NULL if no data meet the criteria. For sfn_data_multi another sfn_data_multi with the sites filtered, and an empty sfn_data_multi if any sites met the criteria

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
library(dplyr)
library(lubridate)

# data
data('ARG_TRE', package = 'sapfluxnetr')

# by timestamp
foo_timestamp <- get_timestamp(ARG_TRE)

foo_timestamp_trimmed <- foo_timestamp[1:100]

sfn_filter(
  ARG_TRE,
  TIMESTAMP %in% foo_timestamp_trimmed
)

# by wind speed value
ws_threshold <- 25

sfn_filter(
  ARG_TRE,
  ws <= ws_threshold
)

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

# by timestamp
sfn_filter(
  multi_sfn,
  between(day(TIMESTAMP), 18, 22)
)

# by wind speed value
sfn_filter(
  multi_sfn,
  ws <= ws_threshold
)

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