Skip to content

Instantly share code, notes, and snippets.

@timriffe
Created April 27, 2023 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timriffe/1f27c4992c35aeefc5be2980d9969d94 to your computer and use it in GitHub Desktop.
Save timriffe/1f27c4992c35aeefc5be2980d9969d94 to your computer and use it in GitHub Desktop.
Code for Saddaf Akhtar's email inquiry
library(tidyverse)
library(DemoTools)
library(readxl)
IN <-read_excel("Data/Saddaf_New_file.xlsx")|>
mutate(age = parse_number(Age),
lx = parse_number(lx))
lx2qx <- function(lx){
-diff(c(lx,0)) / lx
}
IN |>
ggplot(aes(x=age,y=lx,color=Sex,group=Sex)) +
geom_line() +
facet_wrap(Time~State+Residence) +
labs(title = "hard to see which might need smoothing")
IN |>
group_by(Time,State,Residence,Sex) |>
mutate(qx = lx2qx(lx)) |>
ungroup() |>
ggplot(aes(x=age,y=qx,color=Sex,group=Sex)) +
geom_line() +
facet_wrap(Time~State+Residence) +
scale_y_log10() +
labs(title = "seems like only Delhi rural women need smoothing")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment