prepare_forestdata: Prepare global options to run ForestData more easily

Description Usage Arguments Value Examples

View source: R/prepare_forestdata.R

Description

This function counterbalances the high number of arguments in ForestData: many of these simply correspond to the input dataset column names, and have to be specified over and over when running each function. prepare_forestdata allows the user to specify these column names only once and then run all the functions without having to do it again

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
prepare_forestdata(
  data,
  plot_col = getOption("plot_col"),
  id_col = getOption("id_col"),
  time_col = getOption("time_col"),
  status_col = getOption("status_col"),
  size_col = getOption("size_col"),
  measure_type = getOption("measure_type"),
  POM_col = getOption("POM_col")
)

Arguments

data

data.frame, the forest census dataset that you want to treat with the ForestData r-package

plot_col

character, the name of the column containing plot indices

id_col

character, the name of the column containing tree unique ids

time_col

character, the name of the column containing census years or times

status_col

character, the name of the column containing tree vital statuses

size_col

character, the name of the column containing tree size measurements

measure_type

character indicating whether measures are circumferences ("C") or diameter ("D")

POM_col

character, the name of the column containing Point of Measurement (POM) values

Value

NULL, because this function just sets global options to fluidify ForestData's usage.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Loading example dataset
data(example_census)
# specifying the example dataset's column names
prepare_forestdata(example_census,
plot_col="Plot",
id_col="idTree",
time_col="CensusYear",
 status_col = "CodeAlive",
 size_col="Circ",
 measure_type = "C",
 POM_col = "POM")
# checking that the options have been set
getOption("plot_col"); getOption("time_col")
# If the function is run twice with similar specification for one
#or several options, a message indicates that these specific option.s
#kept unchanged
prepare_forestdata(example_census,
plot_col="Plot",
id_col="idTree",
time_col="CensusYear",
status_col = "CodeAlive",
size_col="Circ",
measure_type = "C",
POM_col = "POM")
# If one column name is erroneous, then the function stops with explicit error message
## Not run: 
prepare_forestdata(example_census,
plot_col="SAUCISSON",
id_col="idTree",
time_col="CensusYear",
status_col = "CodeAlive",
size_col="Circ",
measure_type = "C",
POM_col = "POM")
## "Error in prepare_forestdata(example_census,
## plot_col = "SAUCISSON", id_col = "idTree",  :
## plot_col is not any of your dataset's column name..."
  
## End(Not run)

EcoFoG/ForestData documentation built on Jan. 20, 2021, 10:04 a.m.