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 being significantly faster). Is there an easy reason why and how I
could speed up access?

for (m in 1:12) {
for (d in 1:31) {
filter1<-((df[,D]==d) & (df[,M]==m))
if(sum(filter1)>0) {
ctr<-ctr+1
dates[ctr]<-paste(as.character(d),as.character(m))
}
}
}

Thanks...

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch 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