R/data-frame-compare-structure.R
data_frame_compare_structure.Rd
Compare two datasets and throw an error if they have different (a) column counts, (b) column names, and (c) column class
data_frame_compare_structure(d_original, d_current, datestamp_ignore = FALSE)
A data.frame
that serves as the existing metadata file
that potentially needs to be updated. Required.
A data.frame
that contains records potentially missing from
d_original
. Required.
A logical
value indicating whether to ignore a
column called datestamp
. Defaults to FALSE
.
If all check pass, and invisible TRUE
is returned.
The datestamp
column is used in metadata operations like
metadata_update_file()
and data_frame_stack_new()
. In these functions,
the datestamp
column does not have to be present.
# A conventional comparison.
ds_original_1 <- tibble::tibble(
x1 = c(1, 3, 4),
x2 = letters[c(1, 3, 4)],
x3 = c(11, 13, 14)
)
ds_current <- tibble::tibble(
x1 = c(1:5, 1, 5),
x2 = c(letters[1:5], "x", "y"),
x3 = c(11, 12, 13, 14, 15, 11, 15)
)
data_frame_compare_structure(ds_original_1, ds_current)
# When comparing metadata w/ datestamp.
ds_original_2 <- tibble::tibble(
x1 = c(1, 3, 4),
x2 = letters[c(1, 3, 4)],
x3 = c(11, 13, 14),
datestamp = Sys.Date()
)
data_frame_compare_structure(ds_original_2, ds_current, datestamp_ignore = TRUE)