compare_periods_per_plot: compare parameters between periods (years that parameters are...

View source: R/compare_periods_per_plot.R

compare_periods_per_plotR Documentation

compare parameters between periods (years that parameters are measured)

Description

This function compares for each plot (and other provided variables) the differences between periods/years for the column names given in parameter measure_vars. It gives results for differences between subsequent measures (based on period) and between the last and the first measure. All column names of the dataset that are not added to parameter measure_vars, are considered as grouping variables, except for period. If the result is not as expected, please verify that the dataset only consists of grouping variables, variables added to measure_vars and period.

Usage

compare_periods_per_plot(dataset, measure_vars, replace_na_in_vars = NA)

Arguments

dataset

dataframe with values for each period, plot and year, in addition to grouping variables and measure_vars

measure_vars

column names of variables that should be compared between periods (including year)

replace_na_in_vars

column names of variables (measure_vars) in which NA should be replaced by 0 in case at least one record is measured in the same plot_id in the same period. Similar to function add_zeros(), this argument allows to add zeros to end up with records for all species or heights in which measures were taken, even if this specific species or height was absent in the period (and thus the tree volume or number of trees being 0 for all periods and plots in which observations were done). Care should be taken to use this argument: it should only be used for aggregated results of measures (e.d. tree volume, tree number,...) and not for measures of individual trees (which will lead to unwanted additional records) or id's referring to coded tables. It is useless to use this argument if only one result per plot is given.

Value

dataframe with columns plot, year_diff, n_years, grouping variables and differences between periods for each column of measure_vars

Examples

library(forrescalc)
library(dplyr)
treenr_by_plot <-
  read_forresdat_table(tablename = "dendro_by_plot") %>%
  select(
    period, year, plot_id, number_of_tree_species, number_of_trees_ha
  ) %>%
  distinct()
compare_periods_per_plot(
  treenr_by_plot, c("year", "number_of_tree_species", "number_of_trees_ha")
)


inbo/forrescalc documentation built on Sept. 28, 2024, 11:45 a.m.