Learn R Programming

usefun (version 0.5.2)

get_common_names: 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)

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.

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.

See Also

pretty_print_vector_values, pretty_print_string

Examples

Run this code
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)

Run the code above in your browser using DataLab