[R] computing a subset using a loop

burton030 burton69 at hotmail.de
Sun Jul 15 17:31:08 CEST 2012


Dear all,

I have a data frame with different variables and I want to build different
subsets out of this data frame using some conditions and I want to use a
loop because there will be a lot of subsets and this would be saving a lot
of time.
	
I try to give you an overview about my data frame. I have a data frame named
"Baumdaten" and it has one column named "transectID" with different IDs
(A_SEF ,A_LEF, B_SEF etc.) there is another column named "Baumart" with
different species like Abies alba, Betula pendula, etc. I want to build now
subsets and the first subset should be named A_2_SEF_Abies_alba and should
contain all Abies alba that are living in A_2_SEF. So the normal code would
be

A_2_SEF_Abies_alba<-subset(Baumdaten,Baumart=="Abies
alba"&pointID=="A_2_SEF")

 The following step would be to replace Abies alba with Betula pendula and
so on after doing this for A_SEF I have to start with A_LEF so a lot of time
is needing thats why I want to ask if it is possible doing this by using a
loop? Hope you can understand my problem...



--
View this message in context: http://r.789695.n4.nabble.com/computing-a-subset-using-a-loop-tp4636564.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list