On Fri, Jan 1, 2010 at 4:24 PM, milton ruser <milton.ru...@gmail.com> wrote: > Hi Peng, > > If I undertood your point, try this: > > x<-runif(10) > y<-runif(10) > z<-runif(10) > w<-runif(10) > > myDF<-data.frame(cbind(x,y,z,w)) > myDF > > myDF[,c("w","z")]
Thank you! But this is not what I'm asking. I want to know how R internal resolve which columns to use if I specify the column names rather than the indexes. If R does it by search, the access time should be O(log(n)) where n is the number of columns. If R does it by hash, the access time should be O(1). > On Thu, Dec 31, 2009 at 5:15 PM, Peng Yu <pengyu...@gmail.com> wrote: >> >> I don't see where describes the implementation of '[]'. >> >> For example, if x is a matrix or a data.frame, how the lookup of >> 'colname1' is x[, 'colname1'] executed. Does R perform a lookup in the >> a hash of the colnames? Is the reference O(1) or O(n), where n is the >> second dim of x? >> >> ______________________________________________ >> 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. > > ______________________________________________ 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.