get_percentage_of_matches {usefun} | R Documentation |
Get percentage of matches between two vectors
Description
Use this function on two numeric vectors with the same names
attribute
(columns) and same length, in order to find the percentage of common elements
(value matches between the two vectors). The same names
for the two
vectors ensures that their values are logically matched one-to-one.
Usage
get_percentage_of_matches(vec1, vec2)
Arguments
vec1 |
numeric vector with |
vec2 |
numeric vector with |
Value
the percentage of common values (exact matches) between the two vectors. Can only be a value between 0 (no common elements) and 1 (perfect element match). Note that NaN and NA values are allowed in the input vectors, but they will always count as a mismatch.
Examples
vec1 = c(1, 2, 3, 2)
vec2 = c(20, 2, 2.5, 8)
vec3 = c(1, 2, 333, 222)
names.vec = c(seq(1,4))
names(vec1) = names.vec
names(vec2) = names.vec
names(vec3) = names.vec
match.1.2 = get_percentage_of_matches(vec1, vec2)
match.1.3 = get_percentage_of_matches(vec1, vec3)
[Package usefun version 0.5.0 Index]