Hi,
I have a list of 150 strings, say, ap,:
aajkss
dfghjk
sdfghk
...
xxcvvn
And I would l like to grep out these strings from column names in
another file, af,. I've tried the following but none seem to work:
aps - af[,grep(ap, colnames(af), value=TRUE)]
aps - af[,grep(ap, colnames(af),
How about %in% ?
# preparing something that looks like I think your data looks like:
ap - c(aajkss, dfghjk, sdfghk, xxcvvn)
af - matrix(1:10, nrow=2)
colnames(af) - c(aajkss, b, c, dfghjk, e)
# doing what I think you need done:
ap[ap %in% colnames(af)]
Cheers,
B.
(PS. a reproducible example
2 matches
Mail list logo