Quick R Trick: Lists and Data Frames
I didn’t know something better to call this, but you can use lists with data frames as variables to hold multiple field names:
MIN=c('NAICS21','NAICS22','NAICS23')
temp=maz[,MIN] #temp is now a data frame of all rows with just NAICS21, NAICS22, and NAICS23
temp=maz[,c("TAZ",MIN)] #temp is now a data frame of all rows with just TAZ, NAICS21, NAICS22, and NAICS23
This can be incredibly useful in many situations (moving ES202 data to model employment categories is one of many).
Tags: R