[R] deparseDots to get names of all arguments?

William Dunlap wdunlap at tibco.com
Wed Feb 21 03:52:22 CET 2018


Does substitute(...()) do what you want?

> myFunc <- function(x, ...) substitute(...())
> myFunc(y=1/(1:10), x=sin(3:1), z=stop("Oops"), "untagged arg")
$y
1/(1:10)

$z
stop("Oops")

[[3]]
[1] "untagged arg"

> names(.Last.value)
[1] "y" "z" ""


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Feb 20, 2018 at 2:36 PM, Spencer Graves <
spencer.graves at effectivedefense.org> wrote:

> Hi, All:
>
>
>       How can I get the names of all the arguments in dots(...)?
>
>
>       I'm able to get the name of the first argument but not the second:
>
>
>
> deparseDots <- function(...){
>   deparse(substitute(...))
> }
> a <- 1
> b <- 2
> deparseDots(a, b)
> [1] "a"
>
>
>       I'd like to get c('a', 'b').
>
>
>       Thanks,
>       Spencer Graves
>
>
> > sessionInfo()
> R version 3.4.3 (2017-11-30)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: macOS High Sierra 10.13.3
>
> Matrix products: default
> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/
> Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
> LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/
> libRlapack.dylib
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.4.3 tools_3.4.3    yaml_2.1.16
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list