Re: [R] Filtering a data frame using a string for colum header

2009-02-23 Thread Prof Brian Ripley
I would have used 1) != rather than ! ... == 2) !(names(my.df) %in% DrHorrible) since that handles NA names (possible, but not easy to get) better. and note that 3) subset(my.df, select = -DrHorrible) works. On Mon, 23 Feb 2009, Petr PIKAL wrote: Hi r-help-boun...@r-project.org napsal

Re: [R] Filtering a data frame using a string for colum header

2009-02-23 Thread Tony Breyal
Cheers guys, yeah, I was using this bit of code as my work around: filter.col - which(names(my.df)!=DrHorrible) my.df[filter.col] but you guys had better solutions :-) Is there an R wish list somewhere? I tried google but couldn't find a specific location, just various threads here and

[R] Filtering a data frame using a string for colum header

2009-02-22 Thread Tony Breyal
Hi all, I was just radomly playing with R and got the following error when trying to filter a data frame using a string: Angel - c(7,8,6,9,10) Buffy - c(8,9,4,9,10) Firefly - c(9,9,10,10,10) DrHorrible - c(10,9,9,10,10) my.df - data.frame(Angel, Buffy, Firefly, DrHorrible)

Re: [R] Filtering a data frame using a string for colum header

2009-02-22 Thread Chun-Hao Tu
Hi Tony, I GUESS my.df[-DrHorrible] does not tell R which column NUMBER would like to remove. As we know, we could use my.df[-4] and it exactly tells R which column must remvoer from your data. my.df[-4] Angel Buffy Firefly 1 7 8 9 2 8 9 9 3 6 4 10

Re: [R] Filtering a data frame using a string for colum header

2009-02-22 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 23.02.2009 03:44:41: Hi Tony, I GUESS my.df[-DrHorrible] does not tell R which column NUMBER would like to remove. As we know, we could use my.df[-4] and it exactly tells R which column must remvoer from your data. my.df[-4] Angel