Mark Heckmann
2008-Dec-11 18:22 UTC
[R] check if a certain ... argument has been passed on to my user-defined function
Hi,
How can I check if a certain ... argument has been passed on to my
user-defined function or not?
foo <- function(data, ...)
{
### here I want to check whether xlab was passed with the ... arguments
### or if the ... arguments did not contain an xlab argument
}
I tried missing(xlab) , exists(xlab) and several other things but did not
find a solution.
TIA,
Mark
Henrique Dallazuanna
2008-Dec-11 19:07 UTC
[R] check if a certain ... argument has been passed on to my user-defined function
Try this:
foo <- function(data, ...)
{
### here I want to check whether xlab was passed with the ... arguments
### or if the ... arguments did not contain an xlab argument
args <- list(...)
return(ifelse("xlab" %in% names(args), "Exists",
"Missing"))
}
On Thu, Dec 11, 2008 at 4:22 PM, Mark Heckmann <mark.heckmann@gmx.de>
wrote:
> Hi,
>
> How can I check if a certain ... argument has been passed on to my
> user-defined function or not?
>
> foo <- function(data, ...)
> {
> ### here I want to check whether xlab was passed with the ... arguments
> ### or if the ... arguments did not contain an xlab argument
> }
>
> I tried missing(xlab) , exists(xlab) and several other things but did not
> find a solution.
>
> TIA,
> Mark
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
Charles C. Berry
2008-Dec-11 19:10 UTC
[R] check if a certain ... argument has been passed on to my user-defined function
See ?match.call and note the expand.dots arg. HTH, Chuck On Thu, 11 Dec 2008, Mark Heckmann wrote:> Hi, > > How can I check if a certain ... argument has been passed on to my > user-defined function or not? > > foo <- function(data, ...) > { > ### here I want to check whether xlab was passed with the ... arguments > ### or if the ... arguments did not contain an xlab argument > } > > I tried missing(xlab) , exists(xlab) and several other things but did not > find a solution. > > TIA, > Mark > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
Matthias Kohl
2008-Dec-12 04:13 UTC
[R] check if a certain ... argument has been passed on to my user-defined function
and take a look at ?hasArg hth, Matthias Charles C. Berry wrote:> > > See > > ?match.call > > and note the expand.dots arg. > > HTH, > > Chuck > > > On Thu, 11 Dec 2008, Mark Heckmann wrote: > >> Hi, >> >> How can I check if a certain ... argument has been passed on to my >> user-defined function or not? >> >> foo <- function(data, ...) >> { >> ### here I want to check whether xlab was passed with the ... arguments >> ### or if the ... arguments did not contain an xlab argument >> } >> >> I tried missing(xlab) , exists(xlab) and several other things but >> did not >> find a solution. >> >> TIA, >> Mark >> >> ______________________________________________ >> R-help at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > Charles C. Berry (858) 534-2098 > Dept of Family/Preventive > Medicine > E mailto:cberry at tajo.ucsd.edu UC San Diego > http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego > 92093-0901 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Dr. Matthias Kohl www.stamats.de