I have consulted the intro and nabble but have not found an answer to what
should be a simple question, here goes:

I am doing a crosscheck of a data frame and pulling out a single value based
on an inputted value ie based on x i will select y, or if x =2 then my code
returns 7.  

x    y
1   4
2   7
3   10
4   2

My code currently iterates through for as many times as the length of the x
dataframe.  What i would like to do is then is to build a vector for those
values selected.  so if vector x  = 1,4,7 then "new-y" would equal 4, 2, 3.  

x    y
1   4
2   7
3   10
4   2
5   21
6   13
7  3
8  90

I need to ultimetly re-sort my x vector based on the values of y but the
function i am using is the subset function and i cant do it without y being
a vector itself and it is currently only a one value object.

#Creates test Candidates Vector
Candidates=c(100,101,102,103,104,105)

#Creates object equaling the number of candidate TAZs from the main script
Location Choice Model
NumCands1=length(Candidates)

Dev..At=9999999 
        for(i in 1:NumCands1){  
        
        #Renames Location Choice Model generated TAZ's object
        Loc_Mod_TAZ=Candidates[i]

        #Converts Development size from main script to Development density 
function
format
        Dev_Size=Dev..At

        #This is my "y" value in the example i gave above, this is the value 
that i
need put into a           #          vector, a vector that should have as
many values as there are number of candidates
        TAZDetermine_FEET=TAZ_VAC_FEET[TAZ_VAC_FEET$TAZ==Loc_Mod_TAZ,2] 
        
        #Creates new vector based on adaquate vacancy in the TAZ and the
development to be located       
        Newcands=subset(Loc_Mod_TAZ, TAZDetermine_FEET>=Dev_Size) 
        
        
        }

Thanks for the help
Cheers, 
JR
-- 
View this message in context: 
http://www.nabble.com/creating-a-new-vecotr-in-a-for-loop-tp20691663p20691663.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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