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) | |
) |
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
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName api.domain.com | |
ProxyPass / http://127.0.0.1:8000/ | |
ProxyPassReverse / http://127.0.0.1:8000/ | |
</VirtualHost> |
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
# plumber::plumb("country_from_coordinates_api.R")$run(port = 8000) | |
library(plumber) | |
library(httr2) | |
library(rlang) | |
#* @serializer html | |
#* @get / | |
function() { | |
html_content <- '<!DOCTYPE html> |
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
``` r | |
suppressPackageStartupMessages({ | |
library(dplyr) | |
library(tidyr) | |
}) | |
click_data <- tibble( | |
click_id = c("u1", "u1", "u1", "u1", "u1", "u1", "u1", "u1", "u1", "u2", "u2", "u2", "u3", "u3", "u2"), |
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
if (!requireNamespace('rlang')) stop("Please, run install.packages('rlang')") | |
rlang::check_required("pak") | |
pkgs <- rlang::chr( | |
rlang = "r-lib/[email protected]", | |
purrr = "purrr", | |
tidyverse = "tidyverse/tidyverse", | |
tidymodels = "tidymodels/tidymodels", | |
jrrosell = "jrosell/jrrosell@main", | |
) | |
pak::pak(pkgs) |
NewerOlder