Proper phrasing for a loop to convert all .dta files to .csv in a directory
问题 So I have a single instance of dta to csv conversion, and I need to repeat it for all files in a directory. Great help on SO, but I'm still not quite there. Here's the single instance #Load Foreign Library library(foreign) ## Set working directory in which dtw files can be found) setwd("~/Desktop") ## Single File Convert write.csv(read.dta("example.dta"), file = "example.csv") From here, I figure I use something like: ## Get list of all the files file_list<-dir(pattern = ".dta$", recursive=F,