[R] Creating unary operators

McGehee, Robert Robert.McGehee at geodecapital.com
Fri Jan 7 22:25:51 CET 2005


Is it correct (by its lack of mention in the R-Language Definition
Manual) that it is impossible to create a user-defined unary operator?

Ex: (This doesn't work, but it's an example of what I'm looking for)

> "%PLUSONE%" <- function(x) x + 1
> %PLUSONE% 2
[1] 3

And if the above is impossible, am I limited to only the + - ~ ! unary
operators for overloading?

On the same vein, is it correct that "[" and "[[" are the only possible
indexing generics? (Assigning "[" to "[[[" doesn't seem to work, and
nothing else is mentioned in the manual)

My goal is to parse well-defined character strings into R-readable code,
while preserving the structure of this text-language as much as
possible, so I'd rather compute on the R language rather than on this
text language.

Best,
Robert

Robert McGehee
Geode Capital Management, LLC
53 State Street, 5th Floor | Boston, MA | 02109
Tel: 617/392-8396    Fax:617/476-6389
mailto:robert.mcgehee at geodecapital.com



This e-mail, and any attachments hereto, are intended for use by the
addressee(s) only and may contain information that is (i) confidential
information of Geode Capital Management, LLC and/or its affiliates,
and/or (ii) proprietary information of Geode Capital Management, LLC
and/or its affiliates. If you are not the intended recipient of this
e-mail, or if you have otherwise received this e-mail in error, please
immediately notify me by telephone (you may call collect), or by e-mail,
and please permanently delete the original, any print outs and any
copies of the foregoing. Any dissemination, distribution or copying of
this e-mail is strictly prohibited.




More information about the R-help mailing list