SHARE
TWEET

Untitled

a guest Oct 12th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dat1 <- cbind(dat1, data.frame(tot.hh = 0, below.18 = 0, above.18 = 0, below.65 = 0, above.65 = 0))
  2. for(i in 1:length(dat1$hb030)){
  3.   tmp <- subset(dat2, dat2$hb030 == dat1[i,]$hb030 & dat2$hb020 == dat1[i,]$hb020)
  4.   dat1[i,]$tot.hh <- nrow(tmp)
  5.   for(j in 1:length(tmp)){
  6.     tmp.age <- 2006 - tmp[j,]$rb080
  7.     ifelse(tmp.age<18, dat1[i,]$below.18 <- dat1[i,]$below.18+1, dat1[i,]$above.18 <- dat1[i,]$above.18+1)
  8.     ifelse(tmp.age<65, dat1[i,]$below.65 <- dat1[i,]$below.65+1, dat1[i,]$above.65 <- dat1[i,]$above.65+1)
  9.   }
  10. }
RAW Paste Data
Top