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
#' Patch data on the fly. | |
#' | |
#' @param object to be patched | |
#' @param cond logical condition(s) to be evaluated within scope of object | |
#' @param \dots name-value pairs | |
#' @param quiet suppress messages | |
#' | |
#' @examples | |
#' patch(mtcars, where(vs == 0, am == 1), gear = Inf, carb = carb + 10) | |
#' |
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
# You may add here your | |
# server { | |
# ... | |
# } | |
# statements for each of your virtual hosts to this file | |
server{ | |
#server_name localhost; | |
listen 80; | |
location / { |
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(ggplot2) | |
library(dplyr) | |
system.time({ | |
nycflights13::flights %>% | |
mutate(timestring = lubridate::date(time_hour)) | |
}) | |
#0 groups | |
# user system elapsed | |
# 0.048 0.000 0.047 |
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: "Plotly Slideshow Example" | |
author: "Miles McBain" | |
date: "6 August 2016" | |
output: | |
ioslides_presentation | |
--- | |
```{r, include=FALSE} | |
library(AER) | |
library(ggplot2) |
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: "Comment Example" | |
author: "Miles McBain" | |
date: "4 September 2016" | |
output: | |
html_document: | |
css: https://cdn.rawgit.com/MilesMcBain/rmarkdown_comment/master/review.css | |
--- |
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
#Hadley Gapminder Way | |
nested_iris <- | |
iris %>% | |
mutate(Setosa = ifelse(Species == "Setosa", yes=1, no=0) ) %>% | |
select(-Species) %>% | |
gather(key="measure", value="value", Sepal.Length:Petal.Width) %>% | |
nest(Setosa, value) | |
iris_models <- map(nested_iris$data, ~ glm(data=., | |
formula = Setosa ~ value, |
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
#Remove things in the global environment with name like a string you supply. | |
#Like is in the regex match sense, so if you make a slip blowing away most of your environment is possibility. | |
rm_like <- function(pattern = character()) { | |
rm( list = grep(pattern = pattern, | |
x=ls(envir = globalenv()), | |
value = TRUE), | |
envir = globalenv() | |
) | |
} |
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(readr) | |
library(dplyr) | |
library(caret) | |
# from: https://archive.ics.uci.edu/ml/machine-learning-databases/00222/ | |
bank_data <- read_delim("~/Downloads/bank-additional/bank-additional/bank-additional-full.csv", delim=";") | |
bank_data <- bank_data[-caret::nearZeroVar(bank_data)] | |
dummy_var_obj <- | |
bank_data %>% | |
caret::dummyVars(formula = 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
tribble( | |
~Aus.City, ~Pop, | |
"Sydney", "4920970", | |
"Melbourne", "4529496", | |
"Brisbane", "2308720", | |
"Perth", "2039193", | |
"Adelaide", "1316779", | |
"Gold Coast", " 624918", | |
"Newcastle", " 434454", | |
"Canberra", " 424666" |
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(tibble) | |
library(ggplot2) | |
library(dplyr) | |
library(ggrepel) | |
library(ggthemes) | |
stackR <- tribble( | |
~Aus.City, ~R, ~TotalVisits, ~Pop, | |
"Melbourne", "23176", "1544868", "4529496", | |
"Adelaide", "7181", "350850", "1316779", |
OlderNewer