Re: [R] Drop column from a data frame

2010-12-27 Thread David Winsemius
On Dec 26, 2010, at 8:22 PM, John Sorkin wrote: I am trying to drop a column of a data frame. The code below attempts to drop a numeric column (which does not work but gives no error or warning) and a factor column (which does not work but gives an error). I would appreciate someone tellin

Re: [R] Drop column from a data frame

2010-12-26 Thread Phil Spector
John - You can use a syntax similar to what you've tried with the select= argument of the subset function: subset(dfxyz,select=-y) x z 1 1 0 2 2 0 . . . subset(dfxyz,select=-z) x y 1 1 11 2 2 12 . . . - Phil Spector

Re: [R] Drop column from a data frame

2010-12-26 Thread jim holtman
assign NULL to the column: > dfxyz <- data.frame(x=1:10,y=11:20,z=factor(c(rep(0,5),rep(1,5 > dfxyz x y z 1 1 11 0 2 2 12 0 3 3 13 0 4 4 14 0 5 5 15 0 6 6 16 1 7 7 17 1 8 8 18 1 9 9 19 1 10 10 20 1 > dfxyz$y <- NULL > dfxyz x z 1 1 0 2 2 0 3 3 0 4 4 0 5 5 0

[R] Drop column from a data frame

2010-12-26 Thread John Sorkin
I am trying to drop a column of a data frame. The code below attempts to drop a numeric column (which does not work but gives no error or warning) and a factor column (which does not work but gives an error). I would appreciate someone telling me why my code does not work, and suggesting code th