[R] Deleting many columns of a data frame with the same name in a row
Jeff Laake
Jeff.Laake at noaa.gov
Tue Feb 2 17:49:04 CET 2010
Here is one way with an example:
datas=data.frame(x=1:3,A=1:3,A=1:3)
names(datas)=c("x","A","A")
datas
datas=datas[,names(datas)!="A",drop=FALSE]
datas
On 2/2/2010 8:35 AM, anna wrote:
> Hi, I have a data frame datas with half of the columns with the same name
> "A". I want to delete all those columns from the data frame so here is what
> I did:
> datas$A<- NULL
> The problem is that it deleted only one column, I would have to do it as
> many times as there are "A" columns. Is there a way to do it in one time?
> thank you
>
> -----
> Anna Lippel
>
More information about the R-help
mailing list