I have vectors x and type
x <- c("value", "class", "value2", "value3", "class2", "other")
type <- c("value", "class")
and like to match x to type based on type patterns.
E.g. with grepl("^value", x) I get a logical vector of matching patterns for the element "value" in type. Using some function of the apply family helps to generalize, but how to match this to x?
Hope what I'd like to achieve is comprehensible, my desired result in this small example is
c("value", "class", "value", "value", "class")
One Note: I prefer a base r solution over tidyverse!