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
#' @title bibtex_2academic | |
#' @description import publications from a bibtex file to a hugo-academic website | |
#' @author Lorenzo Busetto, phD (2017) <lbusett@gmail.com> | |
#' @modified Peter Paul Pichler (2019) <pichler@pik-potsdam.de> | |
#' @modified R.Andres Castaneda (2019) <acastanedaa@worldbank.org> | |
bibtex_2academic <- function(bibfile, | |
outfold, | |
abstract = FALSE, | |
overwrite = 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
# requires data.table and data.tree | |
dir_size <- function(path = ".", | |
limit = 25, | |
sharet = .1) { | |
# get file from directory path | |
a <- list.files(path, | |
all.files = TRUE, | |
recursive = TRUE, | |
full.names = TRUE) |
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
maxN <- function(x, N=2, decreasing = FALSE){ | |
len <- length(x) | |
if(N>len){ | |
warning('N greater than length(x). Setting N=length(x)') | |
N <- length(x) | |
} | |
if (decreasing == FALSE) { | |
sort(x,partial=len-N+1)[len-N+1] | |
} else { | |
-sort(-x,partial=len-N+1)[len-N+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
/*================================================== | |
project: Examples of the handbook using GMD | |
Author: Andres Castaneda | |
Dependencies: The World Bank | |
---------------------------------------------------- | |
Creation Date: 6 Jul 2018 - 12:03 | |
Modification Date: | |
Do-file version: 01 | |
References: | |
Output: http://eca/povdata/examples_handbook_GMD.DO |
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 |
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
*********** | |
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
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
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
library(tidyverse) | |
# Original data | |
tb <- tibble( | |
x = c("a", "b", "c", "d"), | |
y = c(1, 2, 3, 4) | |
) | |
# Regular condition |
OlderNewer