Last active
August 29, 2015 14:01
-
-
Save azadag/ffbd065d979ceb6d9802 to your computer and use it in GitHub Desktop.
PERWT pums data...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## read in pums data (here to a dataframe called "b" ## | |
library(data.table) | |
dfMa<-data.frame(b$INDb,b$OCC1990b,b$pwmetro,b$perwt) ## toggle detailed | |
colnames(dfa) <- c("IND", "OCC", "PWMETRO","PERWT") | |
###build cross matrix using data.table ##### | |
#### Convert data frame to Data Table | |
dtaa <- data.table(dfMa,key="IND,OCC,PWMETRO") | |
resa <- dtaa[,list(n=sum(PERWT)),by=list(IND,OCC,PWMETRO)] ## sum by weighted variable | |
res1a <-resa[,transform(.SD,pind=n/sum(n)),by=list(IND,PWMETRO)] ## create percent of employment in each industry by city |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment