Defining Multiple Ranges with an if Statement in R
I have a situation where I have a table called districts with a column
called zone, for which 410 values, numbers 1-410 are stored...
Currently, the R code is structured like this:
# add II data to the external matrix
zoneNames <- districts$zone
maxExternalZoneNum <- 99 #assumes externals first in zone numbering and
are less than 99
vehicle[zoneNames > maxExternalZoneNum, zoneNames > maxExternalZoneNum] <-
get(paste(p, "vehicle", sep=""))[zoneNames > maxExternalZoneNum, zoneNames
> maxExternalZoneNum]
assign(paste(p, "vehicle", sep=""),vehicle)
rm(vehicle)
Except that for my purpose, the 99 maxExternalZoneNum does not apply. I
have 1-30 external zone numbers plus another external zone number, 410.
31-409 are "internal" zones, and cannot be renumbered. So I must define
maxExternalZoneNum as a range of values, 1:30 and 410.
What methods could I deploy to efficiently handle the change in the
maxExternalZoneNum so that it does not break the execution of this code?
No comments:
Post a Comment