[R-sig-Geo] Help: Create several ESRI Shape files in a Loop

2012-03-12 Thread Zia Ahmed
I like to write a r-function to create 100 shape files in a loop.I have three data files. Each file has 100 data fields (like sim1, sim2, sim3sim100) with a unique ID fields (Thana_ID). First I want to create 100 data frame from these files and then merge or join each of this 100 files

Re: [R-sig-Geo] Help: Create several ESRI Shape files in a Loop

2012-03-12 Thread Raphael Saldanha
Hi Zia, There are two methods were you can work: the for statement and the tapply function. First, take a good look on these: ?for and ?tapply You can try something like this: for (i in 1:100) sim-cbind(THANA_ID=thana$THANA_ID, logWAS=was$[,i], logGAs=gas$[,i],logTotal=total$[,i]) sim.shp -

Re: [R-sig-Geo] Help: Create several ESRI Shape files in a Loop

2012-03-12 Thread Roman Luštrik
For constructing sim1:n you could probably use mapply. The second part of inserting the data into your read-in shapefiles could possibly be done using sapply. HTH, Roman On Mon, Mar 12, 2012 at 2:53 PM, Zia Ahmed z...@cornell.edu wrote: I like to write a r-function to create 100 shape files

Re: [R-sig-Geo] Help: Create several ESRI Shape files in a Loop

2012-03-12 Thread Raphael Saldanha
Ops! Take off the $ on this line sim-cbind(THANA_ID=thana$THANA_ID, logWAS=was$[,i], logGAs=gas$[,i],logTotal=total$[,i]) This mus be: sim-cbind(THANA_ID=thana$THANA_ID, logWAS=was[,i], logGAs=gas[,i],logTotal=total[,i]) On Mon, Mar 12, 2012 at 11:13 AM, Raphael Saldanha

Re: [R-sig-Geo] Help: Create several ESRI Shape files in a Loop

2012-03-12 Thread Zia Ahmed
I have tried your code, but it create only one shape file (sim100.shp). Thanks Zia for (i in 1:100) sim-cbind(THANA_ID=thana$THANA_ID, logWAS=was[,i], logGAs=gas[,i],logTotal=total[,i]) sim.shp - thana sim.shp@data - merge(thana@data,sim,by.x=THANA_ID,by.y=THANA_ID, all.x=T, sort=F)