This file contains hidden or 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
# getUser cfg = | |
# lookup "username" cfg >>= \uname -> | |
# lookup "age" cfg >>= \ageStr -> | |
# readMaybe (trim ageStr) >>= \age -> | |
# lookup "email" cfg >>= \emailRaw -> | |
# validateEmail (trim emailRaw) >>= \email -> | |
# Just (User uname age email) | |
# 1. Using atomic vectors ----- |
This file contains hidden or 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
# Refrence: https://www.biobits.be/biofunctor/2025/07/30/what-s-r-vector-victor/ | |
# Laboratory experiments are often performed in 96-well plastic plates, with 8 rows (labeled A-H) and 12 columns (labeled 1-12). Each microwell is a separate micro-experiment (labeled A1-H12). | |
rows <- LETTERS[1:8] | |
columns <- 1:12 |> sprintf(fmt = "%02i") | |
# Recycled vectors is not what we want here. | |
paste0(rows, columns) | |
#> [1] "A01" "B02" "C03" "D04" "E05" "F06" "G07" "H08" "A09" "B10" "C11" "D12" |
This file contains hidden or 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
# 1. Preparations & helper functions ----- | |
rlang::check_installed(c("tidyverse", "repurrrsive", "DBI", "duckdb", "ollamar", "ellmer", "glue", "testthat")) | |
library(tidyverse) | |
library(glue) | |
library(repurrrsive) | |
library(DBI) | |
library(duckdb) |
This file contains hidden or 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
load(url("https://github.com/topepo/FES/raw/refs/heads/master/Data_Sets/Ischemic_Stroke/stroke_data.RData")) | |
rlang::check_installed(c("tidyverse", "tidymodels", "corrplot")) | |
library(tidyverse) | |
library(tidymodels) | |
VC_preds <- | |
c("CALCVol", "CALCVolProp", "MATXVol", "MATXVolProp", "LRNCVol", | |
"LRNCVolProp", "MaxCALCArea", "MaxCALCAreaProp", "MaxDilationByArea", |
This file contains hidden or 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
rlang::check_installed(c("vitals", "ellmer", "dplyr", "ggplot2")) | |
library(vitals) | |
library(ellmer) | |
library(dplyr) | |
library(ggplot2) | |
eval_df <- tibble( | |
input = c("What's 2+2?", "What's 2+3?", "What's 2+4?"), | |
target = c("4", "5", "6") |
This file contains hidden or 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
# An experiment creating new functions with type validation using formula notation in R. | |
# For example, for two double argugment inputs and integer output the formula would be: integer ~ double + double | |
library(rlang) | |
library(testthat) | |
type_check_fn <- function(type_name) { | |
switch(as.character(type_name), | |
"integer" = is.integer, | |
"double" = is.double, |
This file contains hidden or 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
rm(list = ls()); rstudioapi::getActiveDocumentContext()$path |> | |
parsermd::parse_rmd(parse_yaml = FALSE) |> | |
parsermd::rmd_select("setup") |> | |
parsermd::as_document() |> | |
purrr::keep(\(x) !stringr::str_detect(x, '^```|^#')) |> | |
parse(text = _) |> | |
eval() |
This file contains hidden or 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
function main() { | |
var spreadsheetUrl = 'https://docs.google.com/spreadsheets/d/id/edit?usp=sharing'; | |
var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl); | |
var pivotedSheet = getOrCreateSheet(spreadsheet, 'PivotedConversionActions'); // New pivoted data sheet | |
var firstDate = '2022-01-01'; | |
var startDate = getDateNDaysAgo(200); | |
var endDate = getDateNDaysAgo(1); | |
This file contains hidden or 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
rlang::check_installed(c("yyjsonr", "plumber2", "httr2", "bench", "callr", "palmerpenguins", "ggbeeswarm", "ggplot2")) | |
library(plumber2) | |
library(palmerpenguins) | |
data(package = 'palmerpenguins') | |
get_penguins <- \(n = 100) { | |
np <- nrow(penguins) | |
idx <- sample(1:np, n, replace = TRUE) | |
penguins[idx, ] |
This file contains hidden or 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(dplyr) | |
library(ggplot2) | |
library(bslib) | |
set.seed(42) | |
data <- data.frame( | |
category = c("A", "B", "C", "D", "E"), | |
value = sample(10:100, 5) | |
) |
NewerOlder