On 30/09/2009, at 10:25 AM, Duncan Murdoch wrote:

On 29/09/2009 4:54 PM, Rolf Turner wrote:
On 30/09/2009, at 9:32 AM, milton ruser wrote:

x=runif(12)
y=runif(12)
w=runif(12)

mydf<-data.frame(cbind(x,y,w))
head(mydf)

mydf<-subset(mydf, select=c(-x,-w))
head(mydf)


        But this doesn't work if NAME1 and NAME2 are ***names***,
        as the terminology would apply.  And that is precisely the
        situation in which one would wish to apply this sort of
        technique.

I'm not completely sure what you're getting at here, but I think milton
is right in this example.  (The original one was missing the "c".)

        milton is right if you explicitly type in the names of the
        columns to be deleted.  But it doesn't work if you store
        the names of the columns as character strings.  That's what
        you would have to do when writing code to handle complex
        situations where you didn't know that column names in advance.

        And if you're not writing code, well why not just do something
        simple like mydf[,2] ???

subset() is weird, it does very strange stuff in the select argument.


        Truer words were never spoken/written.

                cheers,

                        Rolf

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

______________________________________________
R-help@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.

Reply via email to