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
qtile <- function(x, nq = 10) { | |
N <- length(x) | |
csw <- 1:N | |
qp <- floor(csw/((N+1)/nq)) + 1 | |
return(qp) | |
} |
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
local dir "c:\Users\wbxxxxx\AppData\Roaming\Notepad++" | |
local source "https://raw.githubusercontent.com/randrescastaneda/NPplusplus_to_Stata/master" | |
local files "shortcuts.xml stylers.xml userDefineLang.xml" | |
foreach file of local files { | |
copy "`source'/`file'" "`dir'/`file'", replace | |
} | |
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
# labels for charts | |
addUnits <- function(n, d = 0) { | |
labels <- ifelse(n < 1000, n, # less than thousands | |
ifelse(n < 1e6, paste0(round(n/1e3, d), 'k'), # in thousands | |
ifelse(n < 1e9, paste0(round(n/1e6, d), 'M'), # in millions | |
ifelse(n < 1e12, paste0(round(n/1e9, d), 'B'), # in billions | |
'too big!') | |
) | |
) | |
) |
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
bench <- microbenchmark::microbenchmark( | |
times = 100, | |
one = , | |
two = | |
) | |
if (requireNamespace("highcharter")) { | |
hc_dt <- highcharter::data_to_boxplot(bench, | |
time, | |
expr, | |
add_outliers = 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
# ____________________________________________________________________________ | |
# 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") |
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
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
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
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# 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) | |
library(tidyverse) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# load data --------- | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
path <- fs::path("p:/03.pip/estimates/lineup/IND_2016_survey_year.fst") | |
sdt <- fst::read_fst(path = path) |