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
/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */ | |
/*! Adapted from https://jeroen.github.io/clippy/bundle.js by Jeroen Ooms */ | |
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?t |
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
arsenal::tableby() | |
DT | |
flextable | |
formattable | |
gt | |
huxtable | |
knitr::kable() | |
kableExtra | |
mmtable2 | |
modelsummary |
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
x <- palmerpenguins::penguins |> | |
tidyr::drop_na() |> | |
dplyr::mutate( | |
sp = species, | |
bill = bill_length_mm, | |
sex = as.character(sex), | |
.keep = "none" | |
) |> | |
head() |> | |
as.data.frame() |
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: "Autogenerating Rmd sections from a nested list" | |
output: | |
html_document: | |
code_folding: hide | |
--- | |
```{r} | |
remove_blanks_recursively <- function(x) { |
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
#' Check Class of Argument Inputs | |
#' @param ... Objects to be checked for class. | |
#' @param .expected_class Character. The name of the class against which objects | |
#' @param .call Environment. The environment in which this function is called. | |
#' will be checked. | |
#' @noRd | |
check_class <- function( | |
..., | |
.expected_class = c("numeric", "character"), | |
.call = rlang::caller_env() |
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
# As above, but checks for exact name and affiliation matches between | |
# sifters and abstracts. | |
# | |
# It's possible certain abstracts might not get assigned, especially given combos | |
# of sifters writing abstracts, abstracts from sifters' affiliations, assignment | |
# capping and sifter capping. Should probably report any abstracts that have | |
# <assignment_cap assignments. As a precaution, have built in a max_iterations arg | |
# in case of infinite looping, but I don't think that will come into play. | |
.resample <- function(x, ...) x[sample.int(length(x), ...)] # see ?sample |
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
pair_inputs <- function(...) { | |
args <- rlang::dots_list(..., .named = TRUE) | |
args_lengths <- lapply(args, length) | |
pairs <- combn(args_lengths, 2, simplify = FALSE) | |
failed <- lapply(pairs, function(x) max(unlist(x)) %% min(unlist(x)) != 0) | |
if (any(unlist(failed))) { |
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
test_fn <- function(x = 1L, y = "x", z = 1.1) { | |
.check_type(x, y, z, type = "numeric") | |
cat("success") | |
} | |
.check_type <- function(..., type = "numeric") { | |
args <- list(...) | |
arg_names <- as.character(substitute(...())) | |
names(args) <- arg_names |
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
cr2rc <- function(cell_ref) { | |
ref_split <- | |
strsplit(cell_ref, "(?<=[[:alpha:]])(?=[[:digit:]])", perl = TRUE)[[1]] | |
if (length(ref_split) != 2) { | |
stop( | |
"You must supply a cell reference of 1 to 3 letters (the column reference) ", | |
"followed by a number (the row reference), like 'A1' or 'ABC100'.", | |
call. = FALSE |
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
# You can combine: | |
# * {cli} for link-clicking in the console: | |
# https://www.rostrum.blog/posts/2023-09-17-choosethis/ | |
# * the ability to 'monetise' your R packages: | |
# https://www.rostrum.blog/posts/2023-08-01-monetize/ | |
add_one <- function(x) { | |
result <- x + 1 | |
cli::cli_text( | |
"The answer, ", result, |
NewerOlder