Learn R Programming

usefun (version 0.5.2)

get_common_values: Get the common values of two vectors

Description

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

Usage

get_common_values(vec1, vec2, vector.values.str = "nodes", with.gt = TRUE)

Value

the vector of the common values. If there is only one value in common, the vector.values.str gets the last character stripped for readability. If there are no common values, it returns NULL.

Arguments

vec1

vector

vec2

vector

vector.values.str

string. Used for printing, it tell us what are the values 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,2,3)
vec2 = c(3,4,1)

common.names = get_common_values(vec1, vec2)

Run the code above in your browser using DataLab