[R] conditional loop
PDXRugger
J_R_36 at hotmail.com
Wed Oct 1 00:56:55 CEST 2008
I am looking up a number based upon a randomly selected number and then
proceed to the rest of my code if the corresponding value is greater than or
equal to yet another value.
so if
Dev_Size = 14
and my randomly selected number is 102
and i am looking up 102 in the following table
100 21
101 4
102 9
103 52
104 29
So i select the the corresponding value of 102, which is 9 and determine if
it is greater than or equal to Dev_Size and if it is i would proceed, if not
i would like my random number generator to select another number until
complies with the requirement. I have tried below but my while loop doesnt
do what i would like. I cant seem to find a good resource for my problem,
any help would be much appreciated.
Cheers,
JR
#Loads TAZ and corresponding vacant acres data
TAZ_VAC_ACRES=
read.csv(file="C:/LUSDR/Workspace/BizLandPrice/data/TAZ_VAC_ACRES.csv",header=TRUE);
#Test Location Choice Model selected TAZ
while(TAZDetermine <= Dev_Size){
#Randomly generates test TAZ from 100 to 844
RndTAZ=sample(100:844,1,replace=T)
#Renames randomly generated TAZ's object
Loc_Mod_TAZ = RndTAZ
#Create test Development
Dev_Size=50
#Determines vacant acres by TAZ
TAZDetermine=TAZ_VAC_ACRES[TAZ_VAC_ACRES$TAZ==Loc_Mod_TAZ,2]
#Displays number of vacant acres in Location Choice Model selected TAZ
TAZDetermine
}
--
View this message in context: http://www.nabble.com/conditional--loop-tp19751172p19751172.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list