Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. library(HMDHFDplus)
  2. LT <- readHMDweb("USA","fltper_1x1",username = us, password = pw)
  3. head(LT)
  4.  
  5. library(reshape2)
  6. lx <-acast(LT, Age~Year, value.var = "lx")
  7.  
  8. dx <- lx * 0
  9.  
  10. years <- unique(LT$Year)
  11. ages <- unique(LT$Age)
  12.  
  13. NY <- length(years)
  14. na <- length(ages)
  15.  
  16. # first do one year at a time
  17. lx <- rbind(lx, 0)
  18.  
  19. yr <- 20
  20. a <- 20
  21.  
  22. for (yr in 1:NY){ # columns
  23. # then do one age at a time
  24. for (a in 1:na){ # rows
  25. dx[a, yr] <- lx[a, yr] - lx[a + 1, yr]
  26. }
  27. }
  28.  
  29. dx[20,20]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement