How to find common variables in a list of datasets & reshape them in R?
问题 setwd("C:\\Users\\DATA") temp = list.files(pattern="*.dta") for (i in 1:length(temp)) assign(temp[i], read.dta13(temp[i], nonint.factors = TRUE)) grep(pattern="_m", temp, value=TRUE) Here I create a list of my datasets and read them into R, I then attempt to use grep in order to find all variable names with pattern _m, obviously this doesn't work because this simply returns all filenames with pattern _m. So essentially what I want, is my code to loop through the list of databases, find