all_args_here
all_args_here.Rmd
library(saferDev)
Datasets
source("https://raw.githubusercontent.com/safer-r/saferDev/main/dev/other/test2.R")
source("https://raw.githubusercontent.com/safer-r/.github/refs/heads/main/profile/backbone.R")
FUN1 <- function(x, y){
code_for_col <- base::as.vector(x = base::unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y, MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE), recursive = TRUE, use.names = TRUE), mode = "any")
code_for_col2 <- base::as.vector(x = base::unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y)))
middle_bracket <- base::do.call(what = base::c, args = code_for_col)
middle_bracket2 <- base::do.call(what = base::c, args = code_for_col, quote = FALSE, envir = base::parent.frame())
}
FUN2 <- function(x, y){
middle_bracket2 <- base::do.call(what = base::c, args = code_for_col, quote = FALSE, envir = base::parent.frame())
}
Simple examples
# Examples that return an error
# all_args_here(mean)
# all_args_here(test2)
all_args_here(
x = FUN2 # R function
)
>
> INSIDE FUN2(), ARGUMENTS ARE MISSING.
> LINE_NB FUN_NAME
> 1 2 do.call
> 2 2 parent.frame
> FUN_ARGS
> 1 do.call(what = base::c, args = code_for_col, quote = FALSE, envir = base::parent.frame())
> 2 parent.frame()
> FUN_POS DEF_ARGS MISSING_ARG_NAMES
> 1 26 what, args, quote = FALSE, envir = parent.frame()
> 2 100 n = 1 n
> MISSING_ARGS STATUS
> 1 GOOD
> 2 n = 1 parent.frame(n = 1)
Argument export (associated with argument path_out, df_name and overwrite)
all_args_here(
x = FUN2, # R function
export = TRUE, # export the data frame into a .tsv file?
path_out = ".", # pathway of the folder where to export the data frame
df_name = "res.tsv", # name of the exported data frame file
overwrite = TRUE # Overwrite potential df_name file already existing in path_out?
)
>
> INSIDE FUN2(), ARGUMENTS ARE MISSING.
> RESULT EXPORTED IN:
> ./res.tsv
All the arguments
all_args_here(
x = FUN1, # R function
export = FALSE, # export the data frame into a .tsv file?
path_out = ".", # pathway of the folder where to export the data frame.
df_name = "res.tsv", # name of the exported data frame file
overwrite = FALSE, # Overwrite potential df_name file already existing in path_out?
safer_check = TRUE, # perform some "safer" checks? Warning : always set this argument to FALSE if all_args_here() is used inside another safer function.
lib_path = NULL, # absolute pathways of the directories containing the required packages if not in the default directories.
error_text = "" # add information in error messages returned by the function.
)
>
> INSIDE FUN1(), ARGUMENTS ARE MISSING.
> LINE_NB FUN_NAME
> 1 2 as.vector
> 2 2 unlist
> 3 2 mapply
> 4 2 rep
> 5 2 length
> 6 3 as.vector
> 7 3 unlist
> 8 3 mapply
> 9 3 rep
> 10 3 length
> 11 4 do.call
> 12 5 do.call
> 13 5 parent.frame
> FUN_ARGS
> 1 as.vector(x = base::unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y, MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE), recursive = TRUE, use.names = TRUE), mode = "any")
> 2 unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y, MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE), recursive = TRUE, use.names = TRUE)
> 3 mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y, MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE)
> 4 rep(x = y, base::length(x = x))
> 5 length(x = x)
> 6 as.vector(x = base::unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y)))
> 7 unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y))
> 8 mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y)
> 9 rep(x = y, base::length(x = x))
> 10 length(x = x)
> 11 do.call(what = base::c, args = code_for_col)
> 12 do.call(what = base::c, args = code_for_col, quote = FALSE, envir = base::parent.frame())
> 13 parent.frame()
> FUN_POS DEF_ARGS
> 1 23 x, mode = "any"
> 2 43 x, recursive = TRUE, use.names = TRUE
> 3 60 FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE
> 4 94 x, ...
> 5 111 x
> 6 24 x, mode = "any"
> 7 44 x, recursive = TRUE, use.names = TRUE
> 8 61 FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE
> 9 95 x, ...
> 10 112 x
> 11 25 what, args, quote = FALSE, envir = parent.frame()
> 12 26 what, args, quote = FALSE, envir = parent.frame()
> 13 100 n = 1
> MISSING_ARG_NAMES
> 1
> 2
> 3
> 4
> 5
> 6 mode
> 7 recursive, use.names
> 8 MoreArgs, SIMPLIFY, USE.NAMES
> 9
> 10
> 11 quote, envir
> 12
> 13 n
> MISSING_ARGS
> 1
> 2
> 3
> 4
> 5
> 6 mode = "any"
> 7 recursive = TRUE, use.names = TRUE
> 8 MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE
> 9
> 10
> 11 quote = FALSE, envir = parent.frame()
> 12
> 13 n = 1
> STATUS
> 1 GOOD
> 2 GOOD
> 3 GOOD
> 4 GOOD
> 5 GOOD
> 6 as.vector(x = base::unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y)), mode = "any")
> 7 unlist(x = base::mapply(FUN = function(x, y){base::rep(x = y, base::length(x = x))}, x = x, y = y), recursive = TRUE, use.names = TRUE)
> 8 mapply(x = x, y = y,FUN = function(x, y){base::rep(x = y, base::length(x = x))}, MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE)
> 9 GOOD
> 10 GOOD
> 11 do.call(what = base::c, args = code_for_col, quote = FALSE, envir = parent.frame())
> 12 GOOD
> 13 parent.frame(n = 1)