How to exclude a column by name?
On Wed, May 27, 2009 at 12:52:41PM +0200, Paul Hiemstra wrote:
This piece of code does the trick. Most important is the which() command: df = data.frame(a = runif(10), b = runif(10)) df[,-which(names(df) == "a")]
Thanks to you and Linlin. It did not occur to me to use which(); I thought that there would be a shorter way to accomplish this since names are first-class indices for data frames and arrays. (Or are they? What happens under the hood when I write df[,"a"]?)