- Fork the repo and clone the repo to local.
- Remove all existing tests and GitHub Action workflows.
- Add Yihui's example as a test.
Wrap the last step
n - 454
in anexpect_indetical()
call and set the comparison to condition to0
. - Run
rhub::rhub_setup()
to add the R-hub v2 workflow. - Add, commit, and push the above changes.
- Run
rhub::rhub_check()
to run R-hub checks and select options to run the workflow. You might be prompted to set up a GitHub PAT locally and need to do that.
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
desc <- tempfile() | |
curl::curl_download("https://cran.r-project.org/web/packages/tidyverse/DESCRIPTION", destfile = desc) | |
deps <- desc::desc_get_deps(desc) | |
pkgs <- deps[deps$type %in% c("Imports"), "package"] | |
urls <- paste0("https://cloud.r-project.org/web/packages/", pkgs, "/news/news.html") | |
html <- vector("list", length(urls)) | |
for (i in seq_along(urls)) html[[i]] <- rawToChar(curl::curl_fetch_memory(urls[i])$content) | |
markdown <- vector("list", length(urls)) | |
for (i in seq_along(urls)) markdown[[i]] <- paste0(pandoc::pandoc_convert(text = html[[i]], from = "html", to = "markdown"), collapse = "\n") | |
markdown <- markdown[-which(sapply(markdown, grepl, pattern = "# Not Found"))] |
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
n | 1 | 2 | 4 | 8 | 16 | |
---|---|---|---|---|---|---|
dplyr | 5093.77 | 2671.44 | 1447.21 | 810.42 | 446.06 | |
data.table | 1336.79 | 677.94 | 364.5 | 217.75 | 143.95 |
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
# Use `rlang::eval_tidy()` safely | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(comment = "#>", collapse = TRUE, error = TRUE) | |
``` | |
`rlang::eval_tidy()` is a powerful tool that allows you to evaluate R code | |
within a specific environment, often a data frame or a list. | |
However, if used carelessly with user input, it can introduce | |
security vulnerabilities. |
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(reticulate) | |
# Ignore this ---- | |
use_python("/opt/homebrew/bin/python3.10") | |
# reticulate works ---- | |
sdv <- import("sdv") |
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
#' Create a release checklist without requiring context | |
#' | |
#' @param package Package name. | |
#' @param version Release version number. | |
#' @param on_cran Is the package already on CRAN? Default is `TRUE`. | |
#' @param has_news Does the package use `NEWS.md`? Default is `TRUE`. | |
#' @param has_readme Does the package use `README.Rmd`? Default is `FALSE`. | |
#' @param has_lifecycle Does the package use lifecycle? Default is `FALSE`. | |
#' | |
#' @return Release checklist in Markdown format (invisibly). |
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") | |
library("ggplot2") | |
# Container max widths from Bootstrap 5 | |
max_width <- c(540, 720, 960, 1140, 1320) | |
# Output image height scaling factors | |
height_scale <- c(6, 3, 3, 1.5, 1, 1) | |
# Given plot width, find the grid interval index while considering page columns |
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
brew install fontforge | |
brew install woff2 | |
curl -L http://mirrors.ctan.org/fonts/mlmodern.zip > mlmodern.zip | |
unzip mlmodern.zip | |
cd mlmodern/type1/ | |
fontforge -lang=ff -c 'Open($1); Generate($1:r + ".otf")' mlmr12.pfb |
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
# Add custom error messages to specific errors in R | |
error_handler <- function() { | |
rlang::entrace() | |
e <- rlang::last_error()$message | |
if (grepl("there is no package called", x = e)) { | |
message("* This can be a custom error message with multiple lines.") | |
} | |
} | |
if ("rlang" %in% rownames(installed.packages())) { |
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
#' Flatten copy | |
#' | |
#' @param from Source directory path. | |
#' @param to Destination directory path. | |
#' | |
#' @return Destination directory path. | |
#' | |
#' @details | |
#' Copy all `.Rmd`, `.qmd`, and `.md` files from source to destination, | |
#' rename the `.qmd` and `.md` files with an additional `.Rmd` extension, |
NewerOlder