[R] aliases
Gabor Grothendieck
ggrothendieck at myway.com
Tue Oct 21 01:31:42 CEST 2003
How about:
nis.na <- complete.cases
---
From: <Ted.Harding at nessie.mcc.ac.uk>
Hi Folks,
My recent response to Laura Quinn's query about matrix subsetting
reminded of a question.
I wrote:
iDir <- ((Winds[,20]<45)|(Winds[,20]>315))&(!is.na(Winds[,20]))
Now, I find "!is.na" a bit awkward to type, so I might prefer to
type it as "nis.na".
While it is possible to define
nis.na <- function(x){ !is.na(x) }
this involves a slight bloat of overhead in execution since achieving
!is.na involves an extra layer of function call. So is it possible
to define an "alias" so that
nis.na(x)
is _exactly_ equivalent to
!is.na(x)
?
This is not quite the same as defining a simple alias for the name of
a function or other object, though I'd be very interested to know if
this can be done too.
I'm thinking of something which would work like the 'define'
mechanism in C (and some other languages), where
#define nis.na !is.na
would cause simple substitution of "!is.na" for "nis.na" on input
(and you can have parametrised defines too).
With thanks,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 20-Oct-03 Time: 20:38:01
------------------------------ XFMail ------------------------------
_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com
More information about the R-help
mailing list