[R] Trying get away from the "for" loop
dwinsemius at comcast.net
Thu Oct 15 23:46:08 CEST 2009
You do not offer a workable example, but it appears you might be doing
a merge operation.
merge(SubdivisionHouses, BuildingCodes, by.x="BuildYear", by.y="Year")
On Oct 15, 2009, at 5:27 PM, Jason Rupert wrote:
> I just realized the inefficiency of one of my loops so I am trying
> to get rid of it.
> I have two data frames:
> "BuildYear", "SqrFootage", "Exterior"
> "Year", "Codes"
> I am trying to add on the the "Codes" column to according to the
> Currently I am doing the following
> for(hh in 1:unique(BuildingCodes$Year))
> SubdivisionHouses$BuildYear == BuildingCodes$Year)
> BuildingCodes_tmp<-subset(BuildingCodes, BuildingCodes
> $BuildYear == BuildingCodes[hh, ]$BuildYear)
> 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
> Thanks again.
David Winsemius, MD
West Hartford, CT
More information about the R-help