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 silly young man from Clyde | |
In a funeral procession was spied; | |
When asked, "Who is dead?" | |
He giggled and said, | |
"I don't know; I just came for the ride." | |
(source: https://www.brownielocks.com/Limericks.html) |
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: "Untitled" | |
output: html_document | |
--- | |
```{r} | |
library(pixiedust) | |
fit <- lm(mpg ~ qsec * factor(gear) + factor(am), data = mtcars) | |
``` |
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
# Adding lapply versions to http://stackoverflow.com/a/41511889/1017276 | |
library(magrittr) | |
library(data.table) | |
library(microbenchmark) | |
set.seed(pi) | |
nc = 1e3 | |
nr = 1e2 | |
df_m0 = sample(c(1:10, NA_integer_), nc*nr, replace = TRUE) %>% matrix(nr, nc) %>% data.frame | |
df_r = sample(c(1:10), nc*nr, replace = TRUE) %>% matrix(nr, nc) %>% data.frame |
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(magrittr) | |
dummy_ifelse <- function(x) | |
{ | |
if (!is.factor(x)) stop("x is not a factor") | |
lev <- levels(x) | |
lapply(lev[-1], | |
function(l) ifelse(x %in% l, 1, 0)) %>% |
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
#' @name pvalString | |
#' @export pvalString | |
#' | |
#' @title Format P-values for Reports | |
#' @description Convert numeric p-values to character strings according to | |
#' pre-defined formatting parameters. Additional formats may be added | |
#' for required or desired reporting standards. | |
#' | |
#' @param p a numeric vector of p-values. | |
#' @param format A character string indicating the desired format for |
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
source("https://gist.githubusercontent.com/nutterb/23dee9325312d9a71ed5828df1ffd24a/raw/e6d1f2a05b774289246cf28f90902ece4763f92d/packages.R") |
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
medley_all_border <- function(x, part = c("table")) | |
{ | |
part <- | |
match.arg(part, | |
c("table", "head", "body", "interfoot", "foot"), | |
several.ok = TRUE) | |
part <- | |
if ("table" %in% part) | |
{ | |
c("head", "body", "interfoot", "foot") |
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
directorySearch <- function(dir, pattern, ...) | |
{ | |
files <- list.files(dir) | |
suppressWarnings( | |
Code <- lapply(file.path(dir, files), | |
readLines) | |
) | |
files[vapply(Code, |
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) | |
ui <- shinyUI( | |
fluidPage( | |
dateInput(inputId = "date", | |
label = "Signature Date", | |
value = ''), | |
actionButton(inputId = "save_signature", | |
label = "Print Signature"), | |
verbatimTextOutput("date_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
#* A broader experiment on this stack overflow question | |
#* http://stackoverflow.com/questions/33298196/how-to-avoid-a-double-for-loop-when-accessing-all-combinations-of-colums-of-a-ma/33301080?noredirect=1#comment54403634_33301080 | |
#* I really need to find something better to do with my Friday mornings | |
#* Change n to make a larger experiment | |
n <- 1000 | |
#* Change reps to run more cycles in 'microbenchmark' | |
reps <- 10 |