[R] Deleting a column in a dataframe by name

Duncan Murdoch murdoch at stats.uwo.ca
Tue Sep 29 23:25:51 CEST 2009


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".)

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

Duncan Murdoch




More information about the R-help mailing list