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"]?)

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to