[R] Conditionally Removing data from a vector

From: PDXRugger <J_R_36_at_hotmail.com>
Date: Fri, 21 Nov 2008 10:38:19 -0800 (PST)

I am having trouble removing entries from a vector based on the value of the vector and another object value. It works in my pseudo test run:

DEV=400
#Y

CANDS=c(100:105)
#Z

DEVS=c(120,220,320,420,520)

	if(DEV>DEVS)
		 (CANDS=CANDS[which(DEV<DEVS)]) 
     CANDS DEVS
[1,]   100  120
[2,]   101  220
[3,]   102  320
[4,]   103  420

[5,] 104 520
[6,] 105 620

So the result CANDS is 103, 104 and 105 b/c the corresponding DEVS are larger than the DEV(400 in this case).
Now i am trying to implement this into my working code but it doenst seem to work.

#Loads TAZ and corresponding vacant acres data
TAZ_VAC_ACRES= read.csv(file="I:/Research.....csv",header=TRUE);

#Converts vacant acres by TAZ to vacant square footage by TAZ
TAZ_VAC_FEET=cbind(TAZ_VAC_ACRES[1],TAZ_VAC_ACRES[2]*43560)

#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 each candidate TAZ to function variable
	Loc_Mod_TAZ=Candidates[i]

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

	#Determines vacant square feet by TAZ 
	TAZDetermine_FEET=TAZ_VAC_FEET[TAZ_VAC_FEET$TAZ==Loc_Mod_TAZ,2]
	
			#Determines if the Candidate TAZs have sufficient vacancy and creates
vector with TAZs that can accomadate development
			if(Dev_Size>TAZDetermine_FEET)
				(Candidates=Candidates[which(Dev_Size>TAZDetermine_FEET)])

	}

So basically i am starting out with a list of CAndidate TAZs and i want to remove the TAZS that are not big enough to accomadate the Development(Dev..At). My test code works but again i cant get it to run in my workiong code. Anything stupid im missing or maybe a better approach than the "which" function. Remove only seem useful for entire objects so not sure what else would work. Thanks guys and gals

Cheers,
JR

-- 
View this message in context: http://www.nabble.com/Conditionally-Removing-data-from-a-vector-tp20627244p20627244.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_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.
Received on Fri 21 Nov 2008 - 18:57:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 26 Nov 2008 - 01:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive