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(redcapAPI) | |
key <- '' | |
rcon <- redcapConnection("https://redcap.vanderbilt.edu/api/", key, conn, 'MatchedRandomization1') | |
fr_ls <- function(rcon, folder_id = NA, recursive = FALSE) { | |
args <- list(content = 'fileRepository', action = 'list', format = 'csv') | |
if(!is.na(folder_id)) { | |
args$folder_id <- folder_id | |
parent <- folder_id |
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
convert_to_decimal_single <- function(x, from = 2){ | |
coll <- checkmate::makeAssertCollection() | |
checkmate::assert_integerish(x, | |
add = coll) | |
checkmate::assert_integerish(from, | |
len = 1, | |
lower = 1, | |
upper = 36 |
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
atomic_mass <- c( H = 1.008, He = 4.0026, Li = 6.94, Be = 9.0122, | |
B = 10.81, C = 12.011, N = 14.007, O = 15.999, | |
F = 18.998, Ne = 20.180, Na = 22.990, Mg = 24.305, | |
Al = 26.982, Si = 28.085, P = 30.974, S = 32.06, | |
Cl = 35.45, Ar = 39.948, K = 39.098, Ca = 40.078, | |
Sc = 44.956, Ti = 47.867, V = 50.942, Cr = 51.996, | |
Mn = 54.938, Fe = 55.845, Co = 58.933, Ni = 58.693, | |
Cu = 63.546, Zn = 65.38, Ga = 69.732, Ge = 72.630, | |
As = 74.922, Se = 78.971, Br = 79.904, Kr = 83.798, | |
Rb = 85.468, Sr = 87.62, Y = 88.906, Zr = 91.224, |
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
risk_attack_succeed_sim <- function(attack, defend){ | |
while(attack >= 2 && defend > 0){ | |
n_attack <- min(c(3, attack - 1)) | |
n_defend <- min(c(2, defend)) | |
roll_attack <- sample(1:6, n_attack, replace = TRUE) | |
roll_defend <- sample(1:6, n_defend, replace = TRUE) | |
n_compare <- min(c(n_attack, n_defend)) | |
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
quick_summary <- function(df, vars, group = NULL){ | |
group_is_null <- is.null(group) | |
coll <- checkmate::makeAssertCollection() | |
checkmate::assert_data_frame(x = df, | |
add = coll) | |
checkmate::assert_character(x = vars, |
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
tidy.microbenchmark <- function(x, unit, ...){ | |
summary(x, unit = unit) | |
} |
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
# Suppose we have arguments for power and sample size of a two-sample t-test | |
# (Similar to power.t.test, but vectorized. See https://github.com/nutterb/StudyPlanning/blob/devel/R/test_t2.R | |
# delta: Difference of means. (-Inf, Inf) | |
# delta0: Difference under the null hypothesis. (-Inf, Inf) | |
# se: Standard error (0, Inf) | |
# alpha: significance level (0, 1) | |
# power: power of the test (0, 1) | |
### STANDARD ARGUMENT CHECKS ### | |
# 19 lines of code (259 characters) |
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 query_varchar_max | |
#' @title Query a VARCHAR(MAX) Variable from SQL Server | |
#' | |
#' @importFrom RODBCext sqlExecute | |
#' | |
#' @description The RODBC driver to SQL Server (SQL Server Native Client 11.0) | |
#' reports the lenght of a VARCHAR(MAX) variable to be zero. This presents | |
#' difficulties in extracting long text values from the database. Often, the | |
#' ODBC will assume a length of 255 characters and truncate the text to that | |
#' many characters. The approach taken here searches the VARCHAR(MAX) variables |
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) | |
``` |
NewerOlder