cmp_cts | R Documentation |
Compare counts of a list of dataframes
cmp_cts(l, id = "id", include_ids = FALSE)
l |
List of dataframes. |
id |
name of the key variable in the dataframes. |
include_ids |
Logical denoting whether a list column of the ids should
be included in the results. The ids in the list show at which values of
|
Dataframe consisting of columns var
, val
, ...,
vallab1
, vallab2
, ..., & n
,
containing a comparison of the counts of variable values (and their
respective value labels) of the two dataframes in long format.
nv_differ
or cv_differ
& vallabs_differ
are logical columns indicating
if all values / value labels are equal.
# load spss data path <- system.file("examples", "iris.sav", package = "haven") df1 <- haven::read_sav(path) %>% # add id column tibble::rownames_to_column("id") # create a modified copy: df2 <- df1 df2[1, "Species"] <- 2 # compare the dataframes counts: cmp_cts(list(df1, df2)) # compare the dataframes and only show the counts where values have changed: cmp_cts(list(df1, df2)) %>% dplyr::filter(nv1 != nv2) # Create another modified copy df3 <- df2 df3[2, "Species"] <- 3 # compare the dataframes counts: l <- list(df1, df2, df3) cmp <- cmp_cts(l) cmp # compare the dataframes and only show the counts where values have changed: cmp %>% dplyr::filter(!(nv1 == nv2 & nv2 == nv3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.