Skip to content

Instantly share code, notes, and snippets.

library(tidycensus)
library(ggiraph)
library(tidyverse)
library(patchwork)
vt_income <- get_acs(
geography = "county",
variables = "B19013_001",
state = "VT",
year = 2019,
library(tidyverse)
library(rstan)
library(bayesplot)
#code
model_code <- "
data {
int<lower = 2> K; // # of categories
vector[K] priorprobs; //prior
int<lower=0> n_total_1; //total in group 1
@dantonnoriega
dantonnoriega / cool-bash-code.sh
Last active April 21, 2024 20:00
a collection of cool bash scripts
# cool bash codes
# search a directory for all lines that match a pattern (not perfect but useful) ------
## e.g. grep is searching for all lines matching "::" in `R/` to determine package calls
## -h hides the file names; -i ignores case
## sed -E uses regular expressions to search and match groups;
## we then sort and use -u
grep -hi :: -R R/* | sed -E 's/(.*)([ ]+[a-z]+::)(.*)/\2/g' | sort -u
# COUNT COLUMNS -----------------
@javierluraschi
javierluraschi / rstats-rayrender-spark.md
Last active July 10, 2019 21:30
Distributing Ray Tracing in Spark and R using rayrender

This script uses an Amazon EMR Spark cluster with 10 m3.xlarge instances.

Installing

install.packages(devtools)
install.packages(sparklyr)
devtools::install_github("tylermorganwall/rayrender")

system2("hadoop", args = c("fs", "-mkdir", "/rendering"))
@malcolmbarrett
malcolmbarrett / move_slides_to_web.R
Last active April 2, 2019 10:28
Move R Markdown HTML slides to Blogdown and Push to Web
# install.packages(c("here", "fs", "stringr", "purrr", "git2r"))
# to add invisibly in your R profile, open with usethis::edit_r_profile()
# then define it in an environment, e.g.
# .env <- new.env()
# .env$move_slides_to_web <- {function definition}
move_slides_to_web <- function(folder = NULL, index = NULL) {
if (is.null(folder)) {
@vankesteren
vankesteren / lantaarnpaal_utrecht.R
Last active June 29, 2019 05:24
Creating a map with all the lampposts in Utrecht
library(tidyverse)
lights_dat <- read_csv("https://ckan.dataplatform.nl/dataset/83402c68-1c05-4aa5-ab28-2e99d2bc2261/resource/dc10e0ac-351a-49b6-b3db-d0152c29dc02/download/paal-20180906.csv")
pp <-
lights_dat %>%
filter(latitude > 50) %>%
ggplot(aes(x = longitude, y = latitude)) +
geom_point(alpha = 0.03, fill = "#FAFAAB", stroke = 0, pch = 21, size = 1.6) +
geom_point(alpha = 0.8, fill = "#FAFAAB", stroke = 0, pch = 21, size = 0.2) +
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrecos
mrecos / Purrr Grid Search Parallel.R
Last active December 24, 2017 20:46
A bit of code for conducting parallelized random grid-search of randomForest hyperparameters using purrr::map() and futures (for multicore/multisession). This is a bit of a proof-of-concept as there are plenty of ways to iterate over a grid and do CV. Also, especially with randomForest, this is very memory inefficient. However, the approach may …
### ------- Load Packages ---------- ###
library("purrr")
library("future")
library("dplyr")
library("randomForest")
library("rsample")
library("ggplot2")
library("viridis")
### ------- Helper Functions for map() ---------- ###
# breaks CV splits into train (analysis) and test (assessmnet) sets
@timelyportfolio
timelyportfolio / Readme.md
Last active June 8, 2018 11:10
React office-ui-fabric rating component used with R Shiny

As an extension to the blog post React in R, I thought it would be helpful to demonstrate how we can combine a React component with R Shiny.

screenshot of react working with R shiny

Code

library(htmltools)
library(shiny)
library(reactR)
@kanishkamisra
kanishkamisra / sea-ice-extent-months.R
Created June 28, 2017 14:33
Animated plot to rank the months with the most ice extents in the sea. 1979-2016
library(tidyverse)
library(lubridate)
library(extrafont)
library(kani)
library(directlabels)
library(gganimate)
library(scales)
library(tweenr)
sea_ice <- read.csv("https://raw.githubusercontent.com/kanishkamisra/sea-ice-extent/master/seaice.csv") %>% select(-Source.Data)