Argh...

I just realized the inefficiency of one of my loops so I am trying to get rid 
of it.  

I have two data frames:

names(SubdivisionHouses) 
"BuildYear", "SqrFootage", "Exterior"

names(BuildingCodes)
"Year", "Codes"

I am trying to add on the the "Codes" column to according to the "BuildYear"

Currently I am doing the following
SubdivisionHouseMod<-NULL
for(hh in 1:unique(BuildingCodes$Year))
{  
      SubdivisionHouses_tmp<-subset(SubdivisionHouses, 
SubdivisionHouses$BuildYear == BuildingCodes$Year)

      BuildingCodes_tmp<-subset(BuildingCodes, BuildingCodes$BuildYear == 
BuildingCodes[hh, ]$BuildYear)

      SubdivisionHouseMod_tmp<-cbind(SubdivisionHouses_tmp, 
BuildingCodes_tmp$Codes)
      SubdivisionHouseMod<-rbind(SubdivisionHouseMod, SubdivisionHouseMod_tmp)
}

Doing this seems to work, but it also seems to be really inefficient. 

Are there any suggestions of ways to cut this down and speed things up?

Thanks again.

______________________________________________
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