I have a panel that looks like this
country <- c("A","B","C","A","B","C","A","B","C")
industry<- c("X","Y","Z","X","Y","Z","X","Y","Z")
x2006<- sample(1000:100000,9)
x2007<- sample(1000:100000,9)
x2008<- sample(1000:100000,9)
dat <- data.frame (country,industry,x2006,x2007,x2008)
I am doing something very simple like
dat2006 <- dat%>%
select(country,industry,x2006)
then using write.csv
to save it as its own file
What is the best way to do this if I wanted to repeat that and save a separate file for each year (i.e. column) in the data set?