fe_stand | R Documentation |
fe_stand()
provides a user-friendly interface for the constructor
new_fe_stand
. While the constructor does not prevent users from
creating malformed fe_stand
objects, fe_stand
does everything
to achieve a well-defined object mostly based on an initial data.frame
that might be, e.g. drawn out of a user's own data base.
fe_stand(
x,
tree_id_col,
species_id_col,
time_yr_col,
dbh_cm_col,
area_ha,
stand_id = "my_fe_stand",
layer_key_col = NA,
age_yr_col = NA,
height_m_col = NA,
crown_base_height_m_col = NA,
crown_radius_m_col = NA,
removal_col = NA,
ingrowth_col = NA,
n_rep_ha_col = NA,
small_trees = data.frame(),
verbose = TRUE
)
x |
|
tree_id_col |
name of the column in |
species_id_col |
name of the column in |
time_yr_col |
name of the column in |
dbh_cm_col |
name of the column in |
area_ha |
size of the stand area in ha ( |
stand_id |
arbitrary id of the stand ( |
layer_key_col |
name of the column in |
age_yr_col |
name of the column in |
height_m_col |
name of the column in |
crown_base_height_m_col |
name of the column in |
crown_radius_m_col |
name of the column in |
removal_col |
name of the column in |
ingrowth_col |
name of the column in |
n_rep_ha_col |
name of the column in the trees data frame which provides
each tree's representation number per ha. Not required if a stand area is
provided under |
small_trees |
An |
verbose |
|
The initial data.frame
(or even nicer, tibble
) provided by the
user must contain a a minimum set of columns (tree id, species id, time
variable, diameter at breast height). These columns must not contain missing
values. Other columns (containing tree height, height to crown base, crown
radius, tree age) are optional for the user to provide. If provided, they may
contain missing values. If not provided these columns will only contain
missing values in the fe_stand
object. The columns about the trees'
removal and ingrowth status are also optional, but if provided, they must
not contain missing values. If not provided, both columns will be filled
with FALSE
in the resulting fe_stand
object.
The columns from the user's data.frame
that correspond to the columns
defined in fe_stand
objects will turn up in the object under standard
names. All other columns that might be in the data.frame
will be
transferred to the fe_stand
object with their orignal names. It is the
user's responsibility to take care of them.
fe_stand
will automatically add a column n_rep_ha
which
contains for each tree the number of trees it represents per ha. This may
seem redundant if looking at fe_stand
objects alone, but it allows a
broad range of evaluation functions to be applied to different objects
containing trees.
If the user input allows to construct a well-defined fe_stand
object, this object will be returned. If not, the function will terminate
with an error.
# Constructing an fe_stand object based on the minimum required information
# - make data.frame (or, nicer, a tibble) with stand information from
# scratch
candidate_stand <- tibble::tibble(
tree_no = as.character(c(1:100)),
species_id = as_fe_species_tum_wwk_short(c(rep("1", 30), rep("5", 70))),
time_yr = 2022,
dbh = c(rnorm(30, 45, 12), rnorm(70, 38, 9))
)
# - call fe_stand
goal_fe_stand_object <- fe_stand(
x = candidate_stand,
tree_id_col = "tree_no",
species_id_col = "species_id",
time_yr_col = "time_yr",
dbh_cm_col = "dbh",
area_ha = 0.33
)
# Using raw data that could come out of a user's data bases; here one
# example stands (spruce_beech_1_raw) provided with the ForestElementsR
# package
spruce_beech_1_raw$year <- 2022 # No time information in the data frame
spruce_beech_1_raw$species <- as_fe_species_tum_wwk_short(
spruce_beech_1_raw$species
)
spruce_beech_stand <- fe_stand(
spruce_beech_1_raw,
tree_id_col = "no",
species_id_col = "species",
time_yr_col = "year",
dbh_cm_col = "d",
area_ha = 0.49,
stand_id = spruce_beech_1_raw[1, ]$stand,
age_yr_col = "age",
height_m_col = "h",
crown_base_height_m_col = "hcb",
crown_radius_m_col = "crad"
)
# Little summary
spruce_beech_stand |> summary()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.