Re: [R] deleting column from data frame

2010-02-23 Thread Henrique Dallazuanna
One more option: transform(test, Y = NULL) On Tue, Feb 23, 2010 at 9:04 AM, Knut Krueger wrote: > Hi to all, > test <- data.frame("X"=c(1:4),"Y"=c(5:8),"Z"=c(8:11)) > test <- test[,-2] > > Is there a way to specify the col name  "Y" to delete instead the number? > > Kind regards Knut > > __

Re: [R] deleting column from data frame

2010-02-23 Thread S Ellison
test$Y<-NULL test["Z"]<-NULL >>> Todd Ogden 23/02/2010 16:02:01 >>> There might be more elegant ways, but this will do it: test<-test[-match("Y",names(test))] On Feb 23, 2010, at 7:04 AM, Knut Krueger wrote: > Hi to all, > test <- data.frame("X"=c(1:4),"Y"=c(5:8),"Z"=c(8:11)) > test <- test[,

Re: [R] deleting column from data frame

2010-02-23 Thread Todd Ogden
There might be more elegant ways, but this will do it: test<-test[-match("Y",names(test))] On Feb 23, 2010, at 7:04 AM, Knut Krueger wrote: Hi to all, test <- data.frame("X"=c(1:4),"Y"=c(5:8),"Z"=c(8:11)) test <- test[,-2] Is there a way to specify the col name "Y" to delete instead the nu

Re: [R] deleting column from data frame

2010-02-23 Thread David Winsemius
On Feb 23, 2010, at 10:13 AM, adam naples wrote: try test <- subset(test, select = -c(Y)) That approach has the deficiency (or feature?) that it will throw an error if Y is not a column in test, whereas test[ , -grep("Y", names(test))] will not. However, the grep approach will return a

Re: [R] deleting column from data frame

2010-02-23 Thread Benilton Carvalho
i'd use: test[["Y"]] <- NULL b On Tue, Feb 23, 2010 at 4:13 PM, adam naples wrote: > try > > test <- subset(test, select = -c(Y)) > > The key is the  minus sign before c() in the select argument. > You can put in as many columns as you like. > -a > > On Feb 23, 2010, at 11:02 AM, David Winsemiu

Re: [R] deleting column from data frame

2010-02-23 Thread adam naples
try test <- subset(test, select = -c(Y)) The key is the minus sign before c() in the select argument. You can put in as many columns as you like. -a On Feb 23, 2010, at 11:02 AM, David Winsemius wrote: > > On Feb 23, 2010, at 6:04 AM, Knut Krueger wrote: > >> Hi to all, >> test <- data.fram

Re: [R] deleting column from data frame

2010-02-23 Thread Marianne Promberger
Hi Knut, > test <- data.frame("X"=c(1:4),"Y"=c(5:8),"Z"=c(8:11)) > test <- test[,-2] > > Is there a way to specify the col name "Y" to delete instead the number? test[,colnames(test)!="Y"] test[,!colnames(test)%in%"Y"] test[,-grep("Y",colnames(test))] bw,

Re: [R] deleting column from data frame

2010-02-23 Thread David Winsemius
On Feb 23, 2010, at 6:04 AM, Knut Krueger wrote: Hi to all, test <- data.frame("X"=c(1:4),"Y"=c(5:8),"Z"=c(8:11)) test <- test[,-2] Is there a way to specify the col name "Y" to delete instead the number? I believe that negative indexing only works with numeric arguments. You could du