sfn_mutate: Mutate variables by function

Description Usage Arguments Details Value Sapflow and environmental variables Examples

View source: R/sfn_dplyr.R

Description

Port of mutate for sfn_data and sfn_data_multi objects

Usage

1

Arguments

sfn_data

sfn_data or sfn_data_multi object to subset

...

Name-value pairs of expressions to pass to the mutate function.

solar

Logical indicating if solar timestamp must used to subset

Details

'sfn_mutate' function will maintain the same number of rows before and after the modification, so it is well suited to modify variables without creating TIMESTAMP gaps (i.e. to change variable units). For mutating groups of variables at the same time see sfn_mutate_at.

Value

For sfn_data objects, a mutated sfn_data. For sfn_data_multi another sfn_data_multi with the sites mutated

Sapflow and environmental variables

'sfn_mutate' internally joins the sapflow and environmental datasets by the TIMESTAMP, so it is possible to mutate variables conditionally between sapflow and environmental measures (i.e. mutate sapflow when wind is high or radiation is zero). Due to this, at the moment any new variable is dropped when building the final results, so this is ONLY intended to mutate exisiting variables without changing the names.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(dplyr)
library(lubridate)

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

# transform to NAs any wind value above 25
ws_threshold <- 25
sfn_mutate(ARG_TRE, ws = if_else(ws > 25, NA_real_, ws))

## 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_sfn_mutated <- sfn_mutate(
  multi_sfn, ws = if_else(ws > 25, NA_real_, ws)
)

multi_sfn_mutated[['ARG_TRE']]

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