Learn R Programming

sapfluxnetr

sapfluxnetr provides tools for a tidy data analysis for the first global database of sap flow measurements

Examples

You can work with individual sites:

# load packages
library(sapfluxnetr)
library(ggplot2)

# ARG_MAZ example site data
data('ARG_MAZ', package = 'sapfluxnetr')
data('sfn_metadata_ex', package = 'sapfluxnetr')

# plot site sapflow measurements versus vpd
sfn_plot(ARG_MAZ, formula_env = ~ vpd)

# daily sapflow and environmental metrics
arg_maz_metrics <- daily_metrics(
  ARG_MAZ, tidy = TRUE, metadata = sfn_metadata_ex
)
#> [1] "Crunching data for ARG_MAZ. In large datasets this could take a while"
#> [1] "General data for ARG_MAZ"

# plot daily aggregations
ggplot(arg_maz_metrics, aes(x = vpd_q_95, y = sapflow_q_95, colour = pl_code)) +
  geom_point()

You can work with multiple sites also:

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

# plotting the individual sites. It creates a list of plots
plots_list <- sfn_plot(multi_sfn, formula_env = ~ vpd)
plots_list[['AUS_CAN_ST2_MIX']]
#> Warning: Removed 526066 rows containing missing values or values outside the scale range
#> (`geom_point()`).

# daily sapflow standard metrics
multi_metrics <- daily_metrics(
  multi_sfn, tidy = TRUE, metadata = sfn_metadata_ex
)
#> [1] "Crunching data for ARG_TRE. In large datasets this could take a while"
#> [1] "General data for ARG_TRE"
#> [1] "Crunching data for ARG_MAZ. In large datasets this could take a while"
#> [1] "General data for ARG_MAZ"
#> [1] "Crunching data for AUS_CAN_ST2_MIX. In large datasets this could take a while"
#> [1] "General data for AUS_CAN_ST2_MIX"

# plot daily aggregations
ggplot(multi_metrics, aes(x = vpd_q_95, y = sapflow_q_95, colour = si_code)) +
  geom_point(alpha = 0.2)
#> Warning: Removed 10966 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Installation

You can install sapfluxnetr from CRAN:

install.packages('sapfluxnetr')

Be advised, sapfluxnetr is in active development and can contain undiscovered bugs. If you find something not working as expected fill a bug at https://github.com/sapfluxnet/sapfluxnetr/issues

Overview

Please see vignette('sapfluxnetr-quick-guide', package = 'sapfluxnetr') for a detailed overview of the package capabilities.

Copy Link

Version

Install

install.packages('sapfluxnetr')

Monthly Downloads

279

Version

0.1.5

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Victor Granda

Last Published

July 24th, 2025

Functions in sapfluxnetr (0.1.5)

.env_vars_names

helper to return all environmental variable names
norm_diurnal_centroid

Normalized diurnal centroid calculation
.parse_period

.parse_period
.fixed_metrics_funs

helper function to generate the fixed metrics
.timezone_dic

Timezones dictionary
.period_to_minutes

transform period to minutes
read_sfn_data

Read sfn_data from disk
%>%

Reexporting the pipe operator
sfn_data_multi_validity

Validity method for sfn_data_multi class
get_timezone

get the timezone of the site
filter_sites_by_md

Filter the sites by metadata variable values
sfn_data_validity

Validity method for sfn_data class
.sapflow_tidy

.sapflow_tidy helper
metrics_tidyfier

Build a tidy data frame from the metrics results nested list
sfn_metadata_ex

sfn_metadata cache file for example data (ARG_MAZ, ARG_TRE and AUS_CAN_ST2_MIX)
sfn_get_methods

sfn_data get methods
metrics

Complete metrics wrappers
sfn_filter

Filter sfn_data by variable/s value
sfn_vars_to_filter

List all variables that can be used to filter sites
initialize,sfn_data_multi-method

Initialize method for sfn_data multi
initialize,sfn_data-method

Initialize method for sfn_data
sfn_metrics

Metrics summary function
sfn_multi_get_methods

sfn_data_multi get methods
sfn_mutate

Mutate variables by function
show,sfn_data_multi-method

Show method for sfn_data_multi
sfn_get_generics

sfn_data custom get generics
show,sfn_data-method

Show method for sfn_data
sfn_data-class

S4 class for sapfluxnet site data
summarise_by_period

Summaries by period
sfn_data_multi-class

S4 class for sapfluxnet multi-site data
read_sfn_metadata

Read and combine all metadata
sfn_plot

plot method for sfn_data class
sfn_sites_in_folder

list available sites in a db folder
sfn_replacement_methods

sfn_data replacement methods
sfn_mutate_at

Mutate selected columns by function
time_at_events

time at maximum/minimum
sfn_replacement_generics

sfn_data replacement generics
data_coverage

data coverage
as_sfn_data_multi

as_sfn_data_multi helper
.collapse_timestamp

.collapse_timestamp helper
describe_md_variable

Detailed description of metadata variables
.assert_that_period_is_valid

test for character period
.write_metadata_cache

Write metadata cache file to disk
.nightly_daily_cf

Period custom function
.accumulated_posix_aware

accumulated function
.flag

helper function to flag the mutated data in sfn_mutate and sfn_mutate_at
.metadata_architecture

Metadata variables architecture
diurnal_centroid

Diurnal centroid calculation
ARG_MAZ

ARG_MAZ sapfluxnet site
ARG_TRE

ARG_TRE sapfluxnet site
AUS_CAN_ST2_MIX

AUS_CAN_ST2_MIX sapfluxnet site