How to select the columns of a dataframe based on a vector of strings, matching for exact coincidence?
I have a dataframe with the followign column names: NewYork_10 NewYork_20 NewYork3_10 NewYork3_20 NewYork4_10 NewYork4_20 HongKong_10 HongKong_20 SanFrancisco_10 SanFrancisco_20 And I have a vector: list <- c("NewYork", "SanFrancisco") I want a script that creates a new dataframe, selecting those columns that have the exact same string before the underscore. In the example given above, you… Read More How to select the columns of a dataframe based on a vector of strings, matching for exact coincidence?