Re: [R] Variable passed to function not used in function in select=... in subset

From: Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no>
Date: Tue, 11 Nov 2008 09:49:31 +0100

Gabor Grothendieck wrote:
>
> Regarding the convenience it occurs in expressions like this:
>
> iris2 <- subset(iris, select = - Species)
>
> to create a data frame without the Species column.
>

aha! so what's you best guess about the result here:

d = data.frame(a = 1)
d$`-b` = 2
names(d)
# here we go

subset(d, select = -b)
# to b or not to b?

b = "a"
subset(d, select = -b)
# tragedy

d$b = 3
subset(d, select = -b)
# catharsis

(for whatever reason a user may choose to have a column named '-b')

vQ



R-help_at_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. Received on Tue 11 Nov 2008 - 08:53:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 11 Nov 2008 - 10:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive