I need to subset a df to include certain strings. Some of these are full column names, and the following works fine:
testData[,c("FullColName1","FullColName2","FullColName3")]
My problem is that I need to expand this to also include column names that contain specific strings that may partially match to some other column names. These strings include letters and symbols:
"PartString1()","PartString2()"
I tried putting wildcards around these. (I've indicated this below with the prefix "star" because the "*" symbol didn't render correctly.)
testData[ ,c("FullColName1","FullColName2","FullColName3",
"starPartString1()star","starPartString2()star")]
But I'm getting an error message: undefined columns selected. I can't figure out if or how I need grep to make this work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…