Hi,
If I want to know how many arguments a function has, i can do something like length(formals(func))
This works for my functions, but not for some base R functions like is.character
(perhaps because its compiled?)
Reprex below
# Create a function with 3 arguments
func <- function(a, b, c){
message(a, b, c)
}
# Can get number of args with length & formals
length(formals(func))
#> [1] 3
# But this doesn't work for certain base R functions
length(formals(is.character))
#> [1] 0
Created on 2023-01-06 with reprex v2.0.2
Is it possible to programmatically get the number of arguments for any R function?