sfn_mutate {sapfluxnetr} | R Documentation |
Mutate variables by function
Description
Port of mutate
for sfn_data
and
sfn_data_multi
objects
Usage
sfn_mutate(sfn_data, ..., solar = FALSE)
Arguments
sfn_data |
|
... |
Name-value pairs of expressions to pass to the
|
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 existing variables without changing the names.
Examples
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']]