setdiff_nrow: Number of Different Rows between 2 Dataframes

Description Usage Arguments See Also Examples

View source: R/diffs.R

Description

Number of Different Rows between 2 Dataframes

Usage

1

Arguments

x

A dataframe or tibble.

y

A dataframe or tibble.

See Also

Other diff functions: setdiff_col_match()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
library(tidyverse)
test_data <- 
        tibble(
                Group = sample(c("Apple", "Pear"), size = 10, replace = TRUE),
                A     = sample(c(NA_integer_, 1:3), size = 10, replace = TRUE),
                B     = sample(c(NA_integer_, 4:6), size = 10, replace = TRUE),
                C     = sample(c(NA_real_, seq(from = 6.01, to = 6.09, by = 0.01)), size = 10, replace = TRUE),
                D     = sample(c(NA, TRUE, FALSE), size = 10, replace = TRUE)
        ) %>%
        dplyr::mutate(E = B)
        

test_data2 <- dplyr::bind_rows(test_data[1:5,],
                               tibble(
                                               Group = sample(c("Apple", "Pear"), size = 5, replace = TRUE),
                                               A     = sample(c(NA_integer_, 1:3), size = 5, replace = TRUE),
                                               B     = sample(c(NA_integer_, 4:6), size = 5, replace = TRUE),
                                               C     = sample(c(NA_real_, seq(from = 6.01, to = 6.09, by = 0.01)), size = 5, replace = TRUE),
                                               D     = sample(c(NA, TRUE, FALSE), size = 5, replace = TRUE)
                                       ) %>%
                                       dplyr::mutate(E = B))


# Rows difference
setdiff_nrow(x = test_data,
             y = test_data2)

setdiff_nrow(x = test_data2,
             y = test_data)

# Setdiff with a Column Match
setdiff_col_match(x = test_data,
                  y = test_data2 %>%
                        dplyr::mutate(F = 1:10) %>%
                        dplyr::mutate(G = 11:20))

setdiff_col_match(x = test_data2 %>%
                          dplyr::mutate(F = 1:10) %>%
                          dplyr::mutate(G = 11:20),
                  y = test_data)

setdiff_col_match(x = test_data,
                  y = test_data2 %>%
                          rename(F = E))

setdiff_col_match(y = test_data,
                  x = test_data2 %>%
                          rename(F = E))

# Compare Columns
compare_cols(x = test_data,
             y = test_data2)

compare_cols(x = test_data,
                  y = test_data2 %>%
                          dplyr::mutate(F = 1:10) %>%
                          dplyr::mutate(G = 11:20))

compare_cols(x = test_data2 %>%
                          dplyr::mutate(F = 1:10) %>%
                          dplyr::mutate(G = 11:20),
                  y = test_data)


compare_cols(x = test_data,
                  y = test_data2 %>%
                          rename(F = E))

compare_cols(y = test_data,
                  x = test_data2 %>%
                          rename(F = E))

meerapatelmd/rubix documentation built on Sept. 5, 2021, 8:30 p.m.