Learn R Programming

LightLogR (version 0.3.8)

join_datasets: Join similar Datasets

Description

Join Light logging datasets that have a common structure. The least commonality are identical columns for Datetime and Id across all sets.

Usage

join_datasets(
  ...,
  Datetime.column = Datetime,
  Id.column = Id,
  add.origin = FALSE,
  debug = FALSE
)

Value

One of

  • a data.frame of joined datasets

  • a tibble of datasets with missing columns. Only if debug = TRUE

Arguments

...

Object names of datasets that need to be joined.

Datetime.column, Id.column

Column names for the Datetime and id columns. The defaults (Datetime, Id) are already set up for data imported with LightLogR.

add.origin

Should a column named dataset in the joined data indicate from which dataset each observation originated? Defaults to FALSE as the Id column should suffice. Expects a logical.

debug

Output changes to a tibble indicating which dataset is missing the respective Datetime or Id column. Expects a logical and defaults to FALSE.

Examples

Run this code
#load in two datasets
path <- system.file("extdata", 
package = "LightLogR")
file.LL <- "205_actlumus_Log_1020_20230904101707532.txt.zip"
file.env <- "cyepiamb_CW35_Log_1431_20230904081953614.txt.zip"
dataset.LL <- import$ActLumus(file.LL, path, auto.id = "^(\\d{3})")
dataset.env <- import$ActLumus(file.env, path, manual.id = "CW35")

#join the datasets
joined <- join_datasets(dataset.LL, dataset.env)

#compare the number of rows
nrow(dataset.LL) + nrow(dataset.env) == nrow(joined)

#debug, when set to TRUE, will output a tibble of datasets with missing necessary columns
dataset.LL <- dataset.LL %>% dplyr::select(-Datetime)
join_datasets(dataset.LL, dataset.env, debug = TRUE)

Run the code above in your browser using DataLab