get_common_names: Get the common names of two vectors

View source: R/operations.R

get_common_namesR Documentation

Get the common names of two vectors

Description

This function prints and returns the common names of two vectors. The two vectors don't have to be the same length.

Usage

get_common_names(vec1, vec2, vector.names.str = "nodes", with.gt = TRUE)

Arguments

vec1

vector with names attribute

vec2

vector with names attribute

vector.names.str

string. Used for printing, it tell us what are the names of the two vectors (use plural form). Default value: "nodes".

with.gt

logical. Determines if the ">" sign will be appended for nice printing in an R notebook (use with the chuck option results = 'asis'). Default value: TRUE.

Value

the character vector of the common names. If there is only one name in common, the vector.names.str gets the last character stripped for readability. If there is no common names, it returns FALSE.

See Also

pretty_print_vector_values, pretty_print_string

Examples

vec1 = c(1,1,1)
vec2 = c(1,2)
names(vec1) = c("a","b","c")
names(vec2) = c("c","b")

common.names = get_common_names(vec1, vec2)


usefun documentation built on Sept. 15, 2024, 1:06 a.m.