Suppose I have a dataframe ‘H’, like so
C1 C2
a 1
b 1
c 2
d 3
e 4
f 4
g 5
and a list X (as.factor) that goes
"1" "2" "4"
Using the match command,
X2=H[match(X,H$C2),]
only reduces H to three rows and only one instance of each element of X is present (a,c,e). What command should I employ to reduce H to X such that all instances of elements found in X are present (i.e, the reduced table should contain a,b,c,e,f)?
Cheers.
1 Answer