print.file_check_log <- function(x, ...) str(x, ...) as_file_check_log <- function(x) UseMethod("as_file_check_log") as_file_check_log.default <- function(x) { structure(list(x = x, notes = list()), class = "file_check_log") } apply_to_file_check_log <- function(x, fn, ...) { results <- fn(x$x, ...) l <- list(results) call <- rlang::call2(substitute(fn), quote(x), ...) if (!rlang::is_call_simple(call)) { f <- paste0("<unnamed-function-", length(x$notes) + 1, ">") call <- rlang::call2(rlang::sym(f), quote(x), ...) } names(l) <- deparse1(call)names(l) <- deparse1(rlang::call2(substitute(fn), quote(x), ...))x$notes <- c(x$notes, l) x } files <- letters as_file_check_log(files) |> apply_to_file_check_log(head) |> apply_to_file_check_log(tail, 3) |> apply_to_file_check_log(toupper) |> apply_to_file_check_log(stringr::str_subset, "[aeiou]") |> apply_to_file_check_log(function(x) toupper(x))apply_to_file_check_log(stringr::str_subset, "[aeiou]")#> List of 2 #> $ x : chr [1:26] "a" "b" "c" "d" ... #> $ notes:List of 5#> $ notes:List of 4#> ..$ head(x) : chr [1:6] "a" "b" "c" "d" ... #> ..$ tail(x, 3) : chr [1:3] "x" "y" "z" #> ..$ toupper(x) : chr [1:26] "A" "B" "C" "D" ... #> ..$ stringr::str_subset(x, "[aeiou]"): chr [1:5] "a" "e" "i" "o" ... #> ..$ `<unnamed-function-5>`(x) : chr [1:26] "A" "B" "C" "D" ... #> - attr(*, "class")= chr "file_check_log"
Created on 2024-08-22 with reprex v2.1.1