I have got these vectors:
a <- c('x','y','z')
b <- c('w','v','s')
c <- c('x','y')
d <- c('s')
and a data.frame which got the names of the vectors as elements:
df <- data.frame(P= c('c','d','c','d'),R = c('a','b','b','a'))
P R
1 c a
2 d b
3 c b
4 d a
I want the a data frame look like that:
P R P_R
1 c a True
2 d b True
3 c b False
4 d a False
I tried the following to reference my elements in df to the objects a,b,c,d)
df$P_R <- is.element((mget(df$P)),(mget(df$R)))
I got:
Fehler in mget(df$P) : ungültiges erstes Argument
Thanks for your help!