compareVars | R Documentation |
Compares column names in two tables based on a given pattern. Provides information about which columns are present in which tables.
compareVars(x, y, pattern = "")
x |
A data frame representing the first table. |
y |
A data frame representing the second table. |
pattern |
A string pattern used to filter and compare only a subset of variables (column names). |
A list containing:
all
: All column names from both tables.
common
: Column names found in both tables.
onlyX
: Column names found only in the first table (x
).
onlyY
: Column names found only in the second table (y
).
exclusive
: Column names found in only one of the two tables.
# Example tables
table1 <- data.frame(exclusive_1 = 1:5, common_1 = 6:10, common_2 = 11:15)
table2 <- data.frame(common_1 = 16:20, common_2 = 21:25, exclusive_2 = 26:30)
# Compare all columns (no pattern given)
compare_all <- compareVars(table1, table2)
compare_all$common
compare_all$exclusive
compare_all$onlyX
compare_all$onlyY
# compare only columns following a specific pattern
compare_wPattern <- compareVars(table1, table2, pattern = "1")
compare_wPattern$all
compare_wPattern$common
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.