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
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
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
library(tidyverse) | |
# Original data | |
tb <- tibble( | |
x = c("a", "b", "c", "d"), | |
y = c(1, 2, 3, 4) | |
) | |
# Regular condition |
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
ord_nums <- function(n){ | |
ord <- ifelse(n %in% c(11,12,13), "th", | |
ifelse( | |
n %% 10 == 1, 'st', | |
ifelse( | |
n %% 10 == 2, 'nd', | |
ifelse( | |
n %% 10 == 3 , 'rd', "th" |
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
equ_names <- function(x, y) { | |
nms <- names(x)[names(x) %in% names(y)] | |
return(nms) | |
} |
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
*********** | |
cd ~/desktop | |
log using tech.txt, text replace | |
set more off | |
about | |
sysdir | |
adopath | |
creturn list | |
query compilenumber | |
query |
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
add_and <- function(x) { | |
if (!(is.character(x))) { | |
warning("`x` must be character. coercing to character") | |
x <- as.character(x) | |
} | |
lx <- length(x) | |
if (lx == 1) { | |
y <- x | |
} |
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
*##s | |
pcn load price, clear | |
keep countrycode year ref_year survname coverage datatype | |
tempfile pf | |
save `pf' | |
pcn load cpi, clear |