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
foo <- function(x) { | |
d <- "r" | |
s <- with(x , { | |
r <- if (exists("a", inherits = FALSE)) { | |
a + b | |
} else { | |
0 | |
} | |
dd <- if (exists("d", inherits = FALSE)) { | |
1 |
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
alt_coverage <- function(file_name = devtools:::find_active_file() |> | |
fs::path_file(), | |
report = TRUE) { | |
rf <- fs::path("R", file_name) | |
tf <- "tests/testthat" |> | |
fs::path(paste0("test-", file_name)) | |
dd <- covr::file_coverage(source_files = rf, | |
test_files = tf) |
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
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# libraries --------- | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
library(data.table) | |
library(collapse) | |
library(ggplot2) | |
options(pipload.verbose = FALSE) |
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(data.table) | |
ai_nse <- function(dt) { | |
dt[, | |
bottom40 := decile1 + decile2 + decile3 + decile4, | |
][, | |
`:=`( | |
pop_in_poverty = wbpip::get_lh_number_poor( | |
headcount = headcount, | |
pop = pop), |
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(data.table) | |
library(tidyverse) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# load data --------- | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
path <- fs::path("p:/03.pip/estimates/lineup/IND_2016_survey_year.fst") | |
sdt <- fst::read_fst(path = path) |
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
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# load packages --------- | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# library(dtplyr) # worth talking about this. | |
library(data.table) | |
library(tidyverse) | |
# If you don't have installed some of the packages that I use below you, it is | |
# likely that Rstudio is going to let you know that you need to install them. |
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(data.table) | |
url <- "https://raw.githubusercontent.com/PIP-Technical-Team/pipapi/master/inst/plumber/v1/endpoints.R" | |
lns <- readLines(con = url) |> | |
{\(.) .[grep("\\@(get|param)", .)]}() | |
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
rfile <- "R/pip_indicators.R" | |
rfiles <- fs::dir_ls("R", type = "file", regexp = "[rR]$") | |
srch <- 'msrdir <- fs::path\\(maindir, "_aux", branch, measure\\)' | |
rplc <- | |
"if (branch == \"main\") { | |
branch <- \"\" | |
} | |
msrdir <- fs::path(maindir, \"_aux\", branch, measure)" |
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
#' Find variable that are not available in one on another data.frame | |
#' | |
#' @param x data.frame 1 | |
#' @param y data.frame 2 | |
#' | |
#' @return | |
#' @export | |
#' | |
#' @examples | |
extra_vars <- function(x, y) { |
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
# ____________________________________________________________________________ | |
# country level #### | |
sr0 <- pipr::get_stats("SYR", fill_gaps = TRUE, server = "dev") | |
sr1 <- | |
pipr::get_stats("SYR", | |
fill_gaps = TRUE, | |
server = "dev", | |
version = "20220428_2011_02_02_PROD") |
NewerOlder