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(magick) | |
library(purrr) | |
library(ggplot2) | |
# Define variables | |
FRAMES <- 30 | |
MEAN1 <- 0 # Mean of the first group | |
MEAN2 <- 0.2 # Mean of the second group | |
FROM <- 2 | |
TO <- 1500 |
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
# @jrosell: Calculate shortest distance to fuel station from all interest points (useful for feature engineering!) | |
# @jrosell: Use setNames to be sure distance works. | |
# @jrosell: Use rowwise() |> group_split() |> map() |> list_rbind() to be able to get ETA with .progress = TRUE | |
# Original source by @milos-agathon: https://www.youtube.com/watch?v=jmImC0v6qmU | |
# ============================================================================== | |
# Preparations | |
libs <- c( | |
"tidyverse", # Data wrangling and visualization |
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(testthat) | |
expected <- c(0L, 8L, 15L, 0L, 5L, 9L, 0L, 2L) | |
cumsum_cut_base <- function(x, cuts = NULL) { | |
g <- rep(0, length(x)) | |
if (!is.null(cuts)) g[cuts] <- 1 | |
unlist(unname(lapply(split(x, cumsum(g)), \(.x) head(c(0, cumsum(.x)), -1)))) | |
} | |
cumsum_cut_rlang <- function(x, cuts) { |
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(magick) | |
library(lofifonts) # remotes::install_github('coolbutuseless/lofifonts') | |
library(purrr) | |
bitmap_text_coords("Hello", font = 'unifont') |> | |
head() | |
text <- glue::glue("It is a period of civil war. | |
Rebel spaceships, striking | |
from a hidden base, have won |
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
# Original code: https://www.andrewheiss.com/blog/2022/09/26/guide-visualizing-types-posteriors/ | |
# Preparations ----------------------------------------------------------------- | |
cat("repos: ", getOption("repos"), "\n") | |
if (!requireNamespace("rlang", quietly = TRUE)) stop("Please, install.packages('rlang')") | |
if (!requireNamespace("pak", quietly = TRUE)) stop("Please, install.packages('pak')") | |
pkgs <- rlang::chr( | |
"tidyverse", # ggplot, dplyr, purrr and friends | |
"patchwork", # Combine ggplot plots |
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
# Original code: https://tim-tiefenbach.de/post/2023-dplyr-many-models/ | |
# Loading the packages and getting the data ------------------------------------ | |
if (!rlang::is_installed("pak")) install.packages("pak") | |
rlang::check_installed(c( | |
"pak", | |
"dplyr", | |
"tidyr", | |
"broom", |
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(tidyverse) | |
library(rvest) | |
sess <- read_html_live("https://analytics.zoho.com/open-view/your-zoho-table") | |
sess$view() | |
try({ | |
sess$type("#passwordValue", "yourpassword") | |
sess$click("#submitButton") | |
}) |
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
# NOTE: It's not working on Posistron because of rJava, it works on RStudio. | |
if(!"rlang" %in% installed.packages()){ | |
if(!interactive()) { stop("The package \"rlang\" is required.") } | |
cat("The package \"rlang\" is required.\n✖ Would you like to install it?\n\n1: Yes\n2: No\n\nSelection:") | |
if (readLines(n = 1) == "1"){ | |
install.packages("rlang") | |
} | |
} | |
rlang::check_installed( |
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
if(!"rlang" %in% installed.packages()){ | |
if(!interactive()) { stop("The package \"rlang\" is required.") } | |
cat("The package \"rlang\" is required.\n✖ Would you like to install it?\n\n1: Yes\n2: No\n\nSelection:") | |
if (readLines(n = 1) == "1"){ | |
install.packages("rlang") | |
} | |
} | |
rlang::check_installed( | |
"jrrosell (>= 0.0.0.9006)", | |
action = \(pkg,...) { |
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
debug <- FALSE | |
#' @noRd | |
preparations <- \() { | |
cat(glue::glue("preparations")); cat("\n") | |
if(!"rlang" %in% installed.packages()){ | |
if(!interactive()) { stop("The package \"rlang\" is required.") } | |
cat("The package \"rlang\" is required.\n✖ Would you like to install it?\n\n1: Yes\n2: No\n\nSelection:") | |
if (readLines(n = 1) == "1"){ | |
install.packages("rlang") |
NewerOlder