[R] Creating a vector

Patrick Burns pburns at pburns.seanet.com
Sat Dec 13 11:33:46 CET 2008


It seems the crux of the problem is:

#Heres my problem...my attempt below is to build a vector of
length-"candslength" of all of the 
	#"TAZDetermine_FEET" values that are less than or equal to Dev_size.

If you do:

TAZDetermine_FEET[ TAZDetermine_FEET <= Dev_size ]

then you will get the vector of values that you describe (assuming
I understand properly). If you need that to be some other length
than what it actually is, then perhaps 'rep' can be of use.

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

PDXRugger wrote:
> Good day all, 
>     I am having seom trouble building a simple vector.  Below my sample code
> shows what ime trying to do and i have pointed out where the issue is.  What
> happens not is that a single "TAZDetermine_FEET" is selected by i need
> multiple values, as many as there are "cands".  I am thinking that this
> should occur within the for loop and add a "TAZDetermine_FEET" to a new
> vector ("TAZDs") each time the loop goes round but i cant seem to make it
> work using what i know.  Probably simple so sorry and any help will be much
> appreciated, been struggling with this for too long.
>
> Cheers, 
> JR
>
> #test location model TAZs
> TAZS=101:108	
> #Builds test Vacant TAZ vector
> TAZDEVS=c(125481,174581,556789,14755776,9984275,1324587,12457841,4511475)
>
> #Builds dataframe simulating TAZ_VAC_FEET
> TAZ_VAC_FEET=data.frame(TAZS,TAZDEVS)
>
> #Candidate TAZs from location shoice model
> cands=c(101,102,107,108)
>
> #Create Object of length of cands
> candslength=length(cands)
>
> #Test Location Choice Model selected TAZ 
> for(i in i:candslength){
>
> 	#Renames randomly generated TAZ's object
> 	Loc_Mod_TAZ=cands[i]
>
> 	#Create test Development in Sq. Ft. 
> 	Dev_Size=500000
>
> 	#Determines vacant square feet by TAZ 
> 	TAZDetermine_FEET=TAZ_VAC_FEET[TAZ_VAC_FEET$TAZS==Loc_Mod_TAZ,2]
> 	
> 	#Heres my problem...my attempt below is to build a vector of
> length-"candslength" of all of the 
> 	#"TAZDetermine_FEET" values that are less than or equal to Dev_size.
>
>              #heres what i have tried, doesnt get me what i want though
> 	#is.vector(TAZDs)
> 	#TAZDs=list(TAZDetermine_FEET)
> 	#TAZDs=vector(mode = "logical", length = candslength)
> 	
> }
>



More information about the R-help mailing list