[R] Default parameter values in R functions?

2012-04-02 Thread Michael
Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K = 2, spec=c(longrun, transitory), season = NULL, dumvar = NULL) Let's take type as an example... if I omit this parameter when calling the

Re: [R] Default parameter values in R functions?

2012-04-02 Thread R. Michael Weylandt
The first one -- this is implemented by match.arg(). Michael On Mon, Apr 2, 2012 at 5:30 PM, Michael comtech@gmail.com wrote: Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K =

Re: [R] Default parameter values in R functions?

2012-04-02 Thread Bert Gunter
Yes, it's a bit subtle. Argument matching is usually done through match.arg(), so see ?match.arg for an explanation.. (the first chosen). -- Bert On Mon, Apr 2, 2012 at 2:30 PM, Michael comtech@gmail.com wrote: Hi all, I have a newbie question: If I have a function with the following

Re: [R] Default parameter values in R functions?

2012-04-02 Thread Michael
Okay! Thank you both for your help! So it chooses the 1st one by default... Thank you! On Mon, Apr 2, 2012 at 4:43 PM, Bert Gunter gunter.ber...@gene.com wrote: Yes, it's a bit subtle. Argument matching is usually done through match.arg(), so see ?match.arg for an explanation.. (the

Re: [R] Default parameter values in R functions?

2012-04-02 Thread Marc Schwartz
Just to point out another reference, which is the R Language Definition, where in section 4.3.2: http://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching entitled Argument Matching, there are some pointers to the use of match.arg(), leading you to the help page pointed to by Bert