diff_cols: Given two dataframes, which columns are present in one but...

View source: R/dataframe_tools.R

diff_colsR Documentation

Given two dataframes, which columns are present in one but not in the other?

Description

Unlike same_cols(), the order of l and r does matter for diff_cols().

Usage

diff_cols(l, r, side = "both")

Arguments

l

(Dataframe) A dataframe whose column names to compare.

r

(Dataframe) A dataframe whose column names to compare.

side

(Character) "both" or "b" (default) finds columns that are missing from both dataframes. "left" or "l" finds cols in l that are not in r. "right" or "r" finds cols in r that are not in l.

Value

A Character vector with the names of missing columns.

Authors

Examples

iris1 <- iris[, 1:3]
colnames(iris1)
## [1] "Sepal.Length" "Sepal.Width"  "Petal.Length"

iris2 <- iris[, 2:5]
colnames(iris2)
## [1]                "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"

diff_cols(iris1, iris2)
#> [1] "Sepal.Length" "Petal.Width"  "Species"

diff_cols(iris1, iris2, side = "l")
#> [1] "Sepal.Length"

diff_cols(iris1, iris2, side = "r")
#> [1] "Petal.Width"  "Species"


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.