forresdat
to access databaseR/from_forresdat_to_access.R
from_forresdat_to_access.Rd
This function loads one or more tables from git repository forresdat
and saves them in an Access (or SQLite) database.
from_forresdat_to_access(
tables,
database,
remove_tables = FALSE,
plottype = NA,
join_plotinfo = TRUE
)
vector with table names of tables that should be moved
name of (empty) Access database including path in which results should be saved
overwrite existing tables in database? Default is FALSE, which means tables are not overwritten/deleted unless this parameter is explicitly put on TRUE.
possibility to select only data for a certain plot type, e.g. 'CP' for Circular plot or 'CA' for Core area (the default NA means that data from all plots are retrieved)
should table plotinfo
be joined to the chosen table to
add columns forest_reserve
, survey_dendro
/deadw
/reg
/veg
(TRUE or
FALSE) and data_processed
(TRUE or FALSE)?
Default is TRUE.
(This is only possible if the given table contains a column plot_id,
so this parameter should be put FALSE if this column is absent.)
Must be FALSE if you want to load the table plotinfo
itself.
No value is returned, the tables are saved in the access database.
library(forrescalc)
# (add path to your own database here)
path_to_database <- "my-db.sqlite"
from_forresdat_to_access(
tables = "dendro_by_plot",
database = path_to_database
)
#> Rows: 17 Columns: 16
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (1): plottype
#> dbl (15): plot_id, year, period, number_of_tree_species, number_of_trees_ha,...
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 17 Columns: 13
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (2): forest_reserve, plottype
#> dbl (4): plot_id, period, survey_number, year_dendro
#> lgl (7): survey_trees, survey_deadw, survey_veg, survey_reg, game_impact_veg...
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Warning: The dataset only contains presence data and lacks zero observations (except for 1 observation per plot_id and period to indicate that observations are done). Please use function add_zeros() to add zero observations when needed.
# if tables don't contain column plot_id, or it is not relevant to add
# information on the plots, add argument join_plotinfo = FALSE
from_forresdat_to_access(
tables = c("qalive_dead", "qdecaystage"),
database = path_to_database,
join_plotinfo = FALSE
)
#> Rows: 2 Columns: 6
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (2): Value1, Value2
#> dbl (2): ID, Active
#> lgl (2): Value3, OrderField
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Warning: The dataset only contains presence data and lacks zero observations (except for 1 observation per plot_id and period to indicate that observations are done). Please use function add_zeros() to add zero observations when needed.
#> Rows: 8 Columns: 7
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (2): Value1, Value2
#> dbl (3): MasterID, ID, Active
#> lgl (2): Value3, OrderField
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Warning: The dataset only contains presence data and lacks zero observations (except for 1 observation per plot_id and period to indicate that observations are done). Please use function add_zeros() to add zero observations when needed.
file.remove("my-db.sqlite")
#> [1] TRUE