Created
April 27, 2023 10:35
-
-
Save timriffe/1f27c4992c35aeefc5be2980d9969d94 to your computer and use it in GitHub Desktop.
Code for Saddaf Akhtar's email inquiry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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