On Mon, 20 Oct 2003 [EMAIL PROTECTED] wrote:
> 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)
>
No, R doesn't have macros. As R is interpreted, a macro wouldn't
necessarily save you any execution time -- Lisp macros, IIRC, are only
expanded at compile-time.
You can get most of the programming advantages of macros with substitute
and eval, but this is presumably slower rather than faster.
-thomas
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help