get_matched_columns_based_on_value: Detect pairs of columns with same unique values (order does...

View source: R/utilities.R

get_matched_columns_based_on_valueR Documentation

Detect pairs of columns with same unique values (order does not matter) in two dataframes.

Description

Detect pairs of columns with same unique values (order does not matter) in two dataframes.

Usage

get_matched_columns_based_on_value(
  df1,
  df2,
  only_allow_one_match = F,
  treat_fully_contain_as_identical = T
)

Arguments

df1

Dataframe1

df2

Dataframe2

only_allow_one_match

Default FALSE. This parameters is designed to get only one pair of matched columns between two dataframes to supply as parameters for merge function (when TRUE).

Value

A dataframe containing names of matched columns. Or a vetor containing names of matched columns when only_allow_one_match is TRUE and there do have one match.

Examples


vec1 <- data.frame(col1=c('a','a','b','d'), a=c(1,2,3,4))
vec2 <- data.frame(col2=c('d','d','a','b'), b=c(1,2,4,5),a=c(1,2,3,4))
get_matched_columns_based_on_value(vec1, vec2)

#     match_1 match_2
# DF1    col1       a
# DF2    col2       a

vec2 <- data.frame(col2=c('d','d','a','b'))
get_matched_columns_based_on_value(vec1, vec2)

#     match_1
# DF1    col1
# DF2    col2

get_matched_columns_based_on_value(vec1, vec2, only_allow_one_match = T)

# "col1" "col2"



Tong-Chen/ImageGP documentation built on April 14, 2025, 12:54 p.m.