Dennis Fisher
2013-Jan-27 21:10 UTC
[R] Unexpected behavior with abbreviation of an argument to paste
R 2.15.1 OS X Colleagues, I encountered the following unexpected behavior today: The following command yielded the expected result: paste(c("TEXT1", "TEXT2"), collapse="|") Result: [1] "TEXT1|TEXT2" However, abbreviating "collapse" by even one character: paste(c("TEXT1", "TEXT2"), collaps="|") yielded the following: [1] "TEXT1 |" "TEXT2 |" > My experience has been that one can abbreviate these options as long as there is no ambiguity. For example, the "ignore.case" argument for grep can be abbreviated to "ig" (shortening it to a single character creates an ambiguity). Is there something special about "collapse" that I am missing? Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com
Mark Leeds
2013-Jan-27 21:22 UTC
[R] Unexpected behavior with abbreviation of an argument to paste
Hi Dennis: One of function argument matching rules in R that arguments after the dotdotdot have to be matched exactly ( see code for paste below ) so that's why your attempt doesn't work. But I would have been surprised also so I'm not trying to imply that one should know which functions have arguments after dotdotdot and which don't. #============================================================ paste function (..., sep = " ", collapse = NULL) .Internal(paste(list(...), sep, collapse)) <bytecode: 0x01ea9ec4> <environment: namespace:base>> ______________________________________________ > 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. >[[alternative HTML version deleted]]
David Winsemius
2013-Jan-27 21:23 UTC
[R] Unexpected behavior with abbreviation of an argument to paste
On Jan 27, 2013, at 4:10 PM, Dennis Fisher wrote:> R 2.15.1 > OS X > > Colleagues, > > I encountered the following unexpected behavior today: > > The following command yielded the expected result: > paste(c("TEXT1", "TEXT2"), collapse="|") > Result: > [1] "TEXT1|TEXT2" > > However, abbreviating "collapse" by even one character: > paste(c("TEXT1", "TEXT2"), collaps="|") > yielded the following: > [1] "TEXT1 |" "TEXT2 |" > > > My experience has been that one can abbreviate these options as long > as there is no ambiguity. For example, the "ignore.case" argument > for grep can be abbreviated to "ig" (shortening it to a single > character creates an ambiguity). > > Is there something special about "collapse" that I am missing?What you are missing is not special about 'collapse', but is rather a feature shared by any argument after the "dots" in a function's argument list. -- David Winsemius, MD Alameda, CA, USA