Skip to content

Instantly share code, notes, and snippets.

@azadag
Created April 26, 2018 17:17
Show Gist options
  • Save azadag/a06e126eb7014d0153e1497076cec52c to your computer and use it in GitHub Desktop.
Save azadag/a06e126eb7014d0153e1497076cec52c to your computer and use it in GitHub Desktop.
empdataCA4 <- lapply(split(empdataCA3, empdataCA3$reg), function(x) {
x.Date <- (c(CurrentYear, CurrentYear + 1, CurrentYear + 2, CurrentYear + 3, CurrentYear +4 ,CurrentYear +5))
val <- as.ts(na.approx(zoo(x = c(x$Pct[1],NA,NA,NA,NA,x$Pct[2]), x.Date)))
val2 <-predict(td(val~1, to='quarterly', method='denton-cholette', conversion = "last"))
# change the options for interpolation as needed
data.frame(yearQtr= as.yearqtr(time(val2)), test=val2)})
df.dplyr <- as.data.frame(bind_rows(empdataCA4, .id = "groups"))
df.dplyr0 <- as.data.frame(stringr::str_split_fixed(df.dplyr$groups, "_", n=2))
colnames(df.dplyr0) <- c("Bracket", "Region")
df.dplyr01 <- cbind(df.dplyr0,df.dplyr) %>% select(-groups)
df.dplyr01$yearQtr2 <- as.yearqtr(df.dplyr01$yearQtr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment