compare_data | R Documentation |
This function extracts the structures of two data.frames
and compares them,
issuing a series of diagnostics.
compare_data(ref, x, ...) ## Default S3 method: compare_data(ref, x, ...) ## S3 method for class 'data_structure' compare_data( ref, x, use_dim = TRUE, use_names = TRUE, use_classes = TRUE, use_values = TRUE, columns = TRUE, ... ) ## S3 method for class 'data.frame' compare_data(ref, x, ...) ## S3 method for class 'data_comparison' print(x, ..., common_values = TRUE, diff_only = TRUE)
ref |
the reference |
x |
a |
... |
further arguments passed to other methods |
use_dim |
a |
use_names |
a |
use_classes |
a |
use_values |
a |
columns |
the names or indices of columns to compare. Defaults to |
common_values |
when |
diff_only |
when |
The comparison relies on checking differences in:
names of columns
classes of the columns (only the first class is used)
values of the categorical variables
an object of class data_comparison
. This is a named list for
each test
Thibaut Jombart
## no differences compare_data(iris, iris) ## different dimensions compare_data(iris, iris[-1, -2]) compare_data(iris[-1, -2], iris) # inverse ## one variable in common but different class and content compare_data(iris, data.frame(Species = letters, stringsAsFactors = FALSE)) ## Comparing only specific columns iris1 <- iris2 <- iris iris1$letter <- sample(letters[1:3], nrow(iris), replace = TRUE) iris2$letter <- sample(letters[1:8], nrow(iris), replace = TRUE) compare_data(iris1, iris2, columns = "Species") compare_data(iris, iris2, columns = "Species") compare_data(iris, iris1) compare_data(iris1, iris2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.