[R] lapply with argument "X"

Thomas Lumley tlumley at u.washington.edu
Wed Oct 6 20:08:13 CEST 2004


On Wed, 6 Oct 2004 john.gavin at ubs.com wrote:
>
> Fyi, I wanted to show that users have to use single
> character variables with caution because of the existance
> of objects like 'c', 'q', 'T' and 'F'.
> So I tried to say
>
>> xx <- c(letters, LETTERS) ; xx[sapply(xx, exists)]
> [1] "c" "q" "t" "C" "D" "F" "I" "Q" "T" "X"
>
> but the appearance of 'X' undermines my code.

I would have said it actually reinforces the point you are making -- 
inadvertent masking or variable capture is a danger with single letter 
names.

 	-thomas




More information about the R-help mailing list