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
<script> | |
(function() { | |
var divHTML = document.querySelectorAll(".details-open"); | |
divHTML.forEach(function (el) { | |
var preNodes = el.getElementsByTagName("pre"); | |
var outputNode = preNodes[1]; | |
outputNode.outerHTML = "<details open class='output'><summary>Run</summary>" + outputNode.outerHTML + "</details>"; | |
}) | |
})(); | |
(function() { |
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(dplyr) | |
do_if <- function(.data, condition, call){ | |
if(condition){ | |
.x <- .data | |
call_str <- call %>% | |
as.character %>% | |
.[2] |
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
#' A pipable if statement | |
#' | |
#' This function allows to create an if statement that can be used within a pipable workflow | |
#' | |
#' @importFrom magrittr %>% | |
#' @importFrom rlang parse_expr | |
#' @param .data tibble | |
#' @param condition logical test | |
#' @param call a formula descibing a pipe to be evaluated if condition is \code{code} | |
#' @examples |
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
################################################################################ | |
# | |
# ikashnitsky.github.io 2017-06-30 | |
# Produce an RGB coded map of pop structures at NUTS-3 level | |
# Ilya Kashnitsky, [email protected] | |
# | |
################################################################################ | |
# load required packages | |
library(tidyverse) # data manipulation and viz |