mat <- matrix(
c(1, 2, 3, 4),
nrow = 2
)
mat
#> [,1] [,2]
#> [1,] 1 3
#> [2,] 2 4
indice <- integer(0) # mimic `which()` result if nothing 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
f_error <- function(arg, msg, call = rlang::caller_env()) { | |
if (TRUE) { | |
# THe naive way | |
cli::cli_abort(c("{.arg {arg}} is wrong", msg), call = call) | |
} | |
} | |
f_error2 <- function(arg, msg, call = rlang::caller_env(), .envir = parent.frame()) { | |
if (TRUE) { | |
# doesn't work since arg needs to evaluate in current frame, but msg should evaluate in parent frame | |
cli::cli_abort(c("{.arg {arg}} is wrong", msg), call = call, .envir = .envir) |
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
linters: all_linters( | |
# packages = "lintr", | |
line_length_linter = NULL, | |
namespace_linter = NULL, | |
todo_comment_linter = NULL, | |
cyclocomp_linter = NULL, | |
duplicate_argument_linter = NULL, # cli_abort... | |
object_usage_linter = NULL, # problem | |
implicit_integer_linter = NULL, | |
object_length_linter = NULL, # will not rename objects |
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
# this script counts the frequency of function use in order to create a function index that make more sense. | |
# We want to look at what is more user facing. | |
# for now the data source we use is the examples, vignettes, README etc. | |
# Maybe some blog posts in the wild may be used eventually. | |
# TODO go get functions that are used in chaining, and add back `wb_` prefix | |
# TODO reorder R6 methods so that internal ones are not shown first in documentation | |
# TODO add_thread, suggest `create_person()` or link to `wb_creators()`, `wb_person()`, | |
# TODO validate that `wb_dims()`, `wb_color()` are similar to | |
# TODO validate vignette content. discuss if the long / complicated way to add styling is relevant in the vignette. | |
# TODO prefixer https://github.com/dreamRs/prefixer |
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 (FALSE && rlang::is_interactive()) { | |
if (interactive() && !"rlang" %in% rownames(utils::installed.packages())) utils::install.packages("rlang", type = "binary") | |
# options(rlang_interactive = FALSE) | |
if (interactive()) rlang::check_installed(c("pak", "rprojroot", "tidyverse", "gt", "quarto", "skimr", "kit", "sf")) | |
# my packages | |
# if (interactive()) { | |
# invisible(pak::repo_add(sfirke = "https://sfirke.r-universe.dev", olivroy = "https://olivroy.r-universe.dev")) | |
# } |
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
c('TrucRegion') |> | |
stringr::str_replace_all("([:lower:])([:upper:])", "\\1 \\2") |
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
--- | |
output: | |
bookdown::html_document2: | |
theme: bootstrap | |
version: 5 | |
highlight: kate | |
--- | |
```{r setup, include=FALSE} | |
library(knitr) |