[R-sig-eco] help with script

Zapata, Mauricio mauricio.zapata at smurfitkappa.com.co
Thu Aug 11 22:53:13 CEST 2011


Katia,

Try this...
### ---------------------------------------
## read table
tablee<-read.table("table.txt",header=T)

## Function
fun1<-function(i,tablee){
sum(tablee[tablee[,"subparcels"]==tablee[i,"subparcels"] & tablee[,"diameter"]>=tablee[i,"diameter"],"diameter"])
 }
 
## Response
sapply(1:dim(tablee)[1],fun1,tablee)


Mauricio Zapata Cuartas (MSc.)
Planeación Forestal
Smurfit Kappa Cartón de Colombia
Proyecto Forestal
(2) 6914000 2807
Cali, Colombia


-----Mensaje original-----
De: r-sig-ecology-bounces at r-project.org [mailto:r-sig-ecology-bounces at r-project.org] En nombre de Kátia Emidio
Enviado el: jueves, 11 de agosto de 2011 12:44 PM
Para: r-sig-ecology at r-project.org"
Asunto: [R-sig-eco] help with script

Dear all,
Attached there is a table, with columns "subparcel", "nrindividual", "diameter".
Within each subparcel, for each "nrindividual" I need to sum up the diameter of others "nrindividuals"  lying in the subparcel, which "diameter" is larger than or equal the fixed "nrindividual", excluding the diameter of the  fixed individual.
To summarize, I need to visit each individual inside the subparcel and find the others individuals in the same sub-parcel that have the diameter larger than or equal the visited individual and sum their diameter and return these information in a table, having "visited individual", "Subparcel", "diameter sum". I also need to perform these for n subparcels!
Thanks!

Katia Emidio


********************************************************************************
This email and any files transmitted with it may be conf...{{dropped:7}}



More information about the R-sig-ecology mailing list