
Compare the contents of two character vectors
compare_names_qc.RdThis function compares two vectors and identifies:
Usage
compare_names_qc(x, y, output_format = c("simple", "bullet", "badges"))Value
A named list containing:
missingFormatted HTML showing values in
xbut not iny.extraFormatted HTML showing values in
ybut not inx.x_missing_yRaw vector of elements in
xbut not iny.y_missing_xRaw vector of elements in
ybut not inx.
Details
Elements in
xthat are missing iny.Elements in
ythat are missing inx.
It returns both the raw differences and formatted HTML output for use in reports, Shiny apps, or pointblank validation messages.
Three output formats are supported:
"simple"Colored comma-separated strings (HTML).
"bullet"HTML unordered lists.
"badges"Bootstrap-style colored badges.
Examples
x <- c("a", "b", "c")
y <- c("b", "c", "d")
compare_names_qc(x, y)
#> $missing
#> [1] "<span style='color:red; font-weight:bold;'>a</span>"
#>
#> $extra
#> [1] "<span style='color:orange; font-weight:bold;'>d</span>"
#>
#> $x_missing_y
#> [1] "a"
#>
#> $y_missing_x
#> [1] "d"
#>
compare_names_qc(x, y, output_format = "bullet")
#> $missing
#> [1] "<ul style='margin-left:0; padding-left:1em;'><li>a</li></ul>"
#>
#> $extra
#> [1] "<ul style='margin-left:0; padding-left:1em;'><li>d</li></ul>"
#>
#> $x_missing_y
#> [1] "a"
#>
#> $y_missing_x
#> [1] "d"
#>
compare_names_qc(x, y, output_format = "badges")
#> $missing
#> [1] "<span style='background:#d32f2f;color:white;padding:2px 6px;border-radius:4px;'>a</span>"
#>
#> $extra
#> [1] "<span style='background:#ff9800;color:white;padding:2px 6px;border-radius:4px;'>d</span>"
#>
#> $x_missing_y
#> [1] "a"
#>
#> $y_missing_x
#> [1] "d"
#>