[R] Data frame operations getting slower when accessed by index

2007-02-21 Thread Alp ATICI
I have a data frame called df which has about 100 columns but thousands of rows. I set D the index of df$D and M to be the index of df$M. When I run the following loop as it is vs. df[,D] and df[,M] replaced with df$D and df$M there is a real big time difference in completion (with the latter

Re: [R] Data frame operations getting slower when accessed by index

2007-02-21 Thread Prof Brian Ripley
What are D and M? 'Index' here could be a number or a name. In either case, df[[D]] would be the equivalent of df$D. However, your computation does not need a loop at all, let alone two. Try something like tmp - with(df, paste(D, m)) dates - unique(tmp) On Wed, 21 Feb 2007, Alp ATICI wrote: