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("shiny") | |
library("ggplot2") | |
n_obs <- 500L | |
## Define UI for application that draws a histogram | |
ui <- fluidPage( | |
## Application title | |
titlePanel("Visualizing Raw Data vs Residuals"), |
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("simgen") # devtools::install_github("dalejbarr/simgen") | |
library("tibble") | |
library("ggplot2") | |
library("parallel") | |
get_typeI <- function(ns, ni, pops, clust) { | |
res <- mcRun(fitanova, mcr.fnArgs = list(wsbi = FALSE), | |
mcr.cluster = clust, | |
mcr.datFn = mkDf, | |
mcr.datArgs = list(wsbi = FALSE, nsubj = ns, nitem = ni), |
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
## youtube video: https://youtu.be/AJDo9gpkEcg | |
library("readr") | |
library("ggplot2") | |
## read.csv() <- from base R. DON'T USE! | |
hw5 <- read_csv("homework_5.csv") # from readr | |
hw5$A <- factor(hw5$A) | |
hw5$B <- factor(hw5$B) | |
hw5$C <- factor(hw5$C) |
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: "Scottish Babynames" | |
author: "Dale Barr" | |
date: "7 September 2016" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = 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
library(dplyr) | |
library(readr) | |
library(ggplot2) | |
dat <- read_csv("babies-first-names-all-names-all-years2.csv") | |
# pull out babies born in 1998 | |
dat98 <- filter(dat, yr == 1998) %>% | |
group_by(sex) %>% | |
filter(rank <= 5) |
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
## join x and y, replacing any columns in x with matching columns from y | |
## x : the table with values to be replaced | |
## y : the table containing replacement values | |
## cols : the key columns (i.e., cols to join on) | |
replace_join <- function(x, y, cols) { | |
keep <- setdiff(names(x), names(y)) | |
dplyr::inner_join(dplyr::select_(x, .dots = c(cols, keep)), y, cols) | |
} | |
## like above, but: |
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
## Inspired by http://bconnelly.net/2015/06/connecting-r-to-everything-with-ifttt/ | |
## NB: set up IFTTT Maker channel to watch for R_event and then notify. | |
## Get your own personal maker key from https://ifttt.com/maker | |
## Put the code snippet below in ~/.Rprofile | |
buzz_me <- function(msg = "DONE!", event = "R_event") { | |
maker_key <- "yOuR_maKER_keY_GoES_HerE" | |
url <- paste0("https://maker.ifttt.com/trigger/", event, "/with/key/", maker_key) | |
if (requireNamespace("httr", quietly = TRUE)) { | |
invisible(httr::POST(url, body = list(value1 = msg), encode = "json")) | |
} else { |
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 will need to install the package RR53 to run this script | |
# to download and install, use the following two commands: | |
# library(devtools) | |
# install_github("RR53", "dalejbarr") | |
library(RR53) | |
# download Brown et al.'s version of the data from PNAS | |
# you need only do this once to store a local copy | |
# comment out from the script after first use |