[R] For Loop - loading 10 sets of data and calculating

From: PDXRugger <J_R_36_at_hotmail.com>
Date: Fri, 07 Nov 2008 10:48:16 -0800 (PST)

I am trying to simplify my code by adding a for loop that will load and compute a sequence of code 10 time. They way i run it now is that the same 8 lines of code are basically reproduced 10 times. I would like to replace the numeric value in the code (e.g. Bin1, Bin2....Bin10) each time the loop goes around. Below i tried doing this with a simple for loop and adding the string character before each numeric value. I need to first load the data then calculate, im sure this is possible as i have seen it done but cant seem to reproduce it in my own code. Hope my question is clear and i hope someone can offer some guidance.


for (i in 1:10) {


#Loads bin data frame from csv files with acres and TAZ data
Bin$i_main <-

#Separates Acres data from main data and converts acres to square feet

#Separates TAZ data from main data


#Separates TAZ data from main data and converts acres to square feet

#Sums each parcel acreage data of the bin

#Creates data frame of cumlative percentages of each parcel of bin

#Calculates the probability of choosing particular parcel from bin

#Combines parcel acreage data and cumlative percentage data
Bin$iMain.data = cbind(Bin%i_Acres,Bin$i_parprob,Bin$i_TAZ,Bin$i_TAZvacant) }

View this message in context: http://www.nabble.com/For-Loop---loading-10-sets-of-data-and-calculating-tp20386673p20386673.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
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 07 Nov 2008 - 19:51:33 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 Fri 07 Nov 2008 - 21:30:23 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