Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(HMDHFDplus)
- LT <- readHMDweb("USA","fltper_1x1",username = us, password = pw)
- head(LT)
- library(reshape2)
- lx <-acast(LT, Age~Year, value.var = "lx")
- dx <- lx * 0
- years <- unique(LT$Year)
- ages <- unique(LT$Age)
- NY <- length(years)
- na <- length(ages)
- # first do one year at a time
- lx <- rbind(lx, 0)
- yr <- 20
- a <- 20
- for (yr in 1:NY){ # columns
- # then do one age at a time
- for (a in 1:na){ # rows
- dx[a, yr] <- lx[a, yr] - lx[a + 1, yr]
- }
- }
- dx[20,20]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement