Learn R Programming

Rveg (version 0.1.8)

RvegMerge: RvegMerge: Merge Two Rveg Databases

Description

Combines two separate Rveg databases into a single, unified database. This function cleanly merges both the species composition data (REL) and the environmental plot header data (HEAD), and seamlessly combines their metadata.

Usage

RvegMerge(database_1, database_2, export = "export")

Value

Writes two linked CSV files to the location specified by export, representing the combined Rveg database.

Arguments

database_1

Character. The path and name of the first Rveg database (e.g., "path/to/db1").

database_2

Character. The path and name of the second Rveg database (e.g., "path/to/db2").

export

Character. The output path and name where the merged database files (*HEAD.csv and *REL.csv) will be saved. Defaults to a temporary directory.

Details

During the merge process:

  • Relevé Re-indexing: The relevé columns from both databases are sequentially re-indexed (e.g., X1, X2, ..., Xn) to prevent column name collisions.

  • Checklist Validation: The function checks the metadata of both databases to ensure they were built using the same species checklist. If the checklists differ, it will issue a warning, though the merge will still proceed.

  • Missing Species: If a species exists in one database but not the other, the function automatically fills the absences with 0.

  • Metadata: The total number of relevés is updated, and any custom species (extra_spec) from both databases are concatenated together.

See Also

RvegCombine for manipulating data within a single database, addReleve for adding individual relevés.

Examples

Run this code
# Example: Merging the built-in database with itself
db_path <- file.path(path.package("Rveg"), "extdata/ExampleDB", "example_1")

RvegMerge(
  database_1 = db_path,
  database_2 = db_path
)

Run the code above in your browser using DataLab