This file contains hidden or 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
# note, our citation lookup needs an openalex paper id | |
# but you probably only have the doi. This does the translation | |
# this returns a full url, where the id is the last part | |
get_openalex_id_from_doi <- function(doi, email) { | |
base_url <- "https://api.openalex.org/works/doi:" | |
doi_encoded <- URLencode(doi, reserved = TRUE) | |
url <- paste0(base_url, doi_encoded, "?mailto=",email) | |
res <- httr::GET(url, httr::user_agent(email)) |
This file contains hidden or 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
# See also https://gist.github.com/timriffe/f820143e939f9262b3083122e1ce49ae | |
# for semantic scholar. Sorry output isn't harmonized | |
get_citing_papers_opencite <- function(doi){ | |
openciteurl <- paste0( "https://opencitations.net/index/coci/api/v1/citations/",doi ) | |
result <- rjson::fromJSON(file = openciteurl) | |
result |> lapply(as_tibble) |> bind_rows() | |
} | |
get_second_order_citations_opencite <- function(doi){ | |
citing <- get_citing_papers_opencite(doi) |
This file contains hidden or 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
# get the semantic scholar method | |
library(httr) | |
library(jsonlite) | |
library(dplyr) | |
get_citing_papers <- function(doi, page_size = 100, max_results = 10000) { | |
base_url <- paste0("https://api.semanticscholar.org/graph/v1/paper/DOI:", | |
URLencode(doi, reserved = TRUE), | |
"/citations") | |
fields <- "citingPaper.paperId,citingPaper.title,citingPaper.citationCount" | |
This file contains hidden or 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
# download Excel from here: | |
# https://docs.google.com/spreadsheets/d/1zJPZ9uu6NpYruV8utJ-Cby4BGMpHw4XE/edit?usp=sharing&ouid=107044799582363262397&rtpof=true&sd=true | |
library(tidyverse) | |
library(readxl) | |
library(colorspace) | |
dat <- read_excel("Data/graficos_prev_ratio_antia_yolanda.xlsx", sheet = "table") | |
p <- | |
dat %>% |
This file contains hidden or 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(scholar) | |
library(googlesheets4) | |
library(tidyverse) | |
gs4_auth(email = "[email protected]") | |
authors <- read_sheet(ss = "https://docs.google.com/spreadsheets/d/18RWKaMvkUOGp_URLwRu-3jTLUz2iI4y3oN_hu8MLoRg/edit#gid=0") | |
authors | |
pubsi <- list() | |
for (i in 1:nrow(authors)){ | |
pubsi[[i]] <- get_publications(id = authors$scholar_id[i], |
This file contains hidden or 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(rvest) | |
library(httr) | |
options(timeout = 1e6) | |
cdc_url <- "https://www.cdc.gov/nchs/data_access/vitalstatsonline.htm" | |
pg <- read_html(cdc_url) | |
test <- html_attr(html_nodes(pg, "a"), "href") |
This file contains hidden or 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(HMDHFDplus) | |
library(tidyverse) | |
library(data.table) | |
# read and reshape births by year, age, order | |
Bxi <- readHFDweb("SWE","birthsRRbo", | |
username = Sys.getenv("us"), | |
password = Sys.getenv("pw"))|> | |
select(-OpenInterval, -Total) |> | |
pivot_longer(B1:B5p, names_to = "order", values_to = "Bxi") |> |
This file contains hidden or 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(HMDHFDplus) | |
fert <- readHFDweb("USA", | |
"asfrRR", | |
username = Sys.getenv("us"), | |
password = Sys.getenv("pw")) | |
# ASFR as function of rates: | |
# decomposition result is just the age-specific rate differences | |
fert |> |
This file contains hidden or 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
Mxc <- structure(c(1.93e-05, 1.02e-05, 5.84e-07, 7.03e-07, 5.57e-07, | |
3.75e-06, 8.07e-06, 1.21e-05, 2.24e-05, 3.27e-05, 5.34e-05, 6.14e-05, | |
8.53e-05, 0.000137, 0.000166, 0.000221, 0.000257, 0.000337, 0.000445, | |
0.000825, 0.000991, 0.001587473, 0.000106, 4.83e-06, 5.85e-07, | |
2.84e-07, 2.02e-07, 1.19e-06, 2.89e-06, 2.86e-06, 9.94e-06, 1.02e-05, | |
2.21e-05, 3.92e-05, 7.44e-05, 0.000113, 0.000183, 0.000312, 0.000458, | |
0.000939, 0.00176391, 0.003744596, 0.006769298, 0.011084971, | |
0, 0, 0, 0, 0, 3.12e-07, 3.89e-07, 6.73e-08, 6.58e-07, 2.9e-06, | |
8.29e-06, 1.8e-05, 5.81e-05, 0.000141, 3e-04, 0.000607, 0.00120023, | |
0.002377745, 0.004082495, 0.00780333, 0.014229324, 0.021679745, |
NewerOlder