Skip to content
Prev 207106 / 398503 Next

loop on list levels and names

One way is :

dataset = data.table(ssfamed)
dataset[, < whatever "some functions" are on Asfc, Smc, epLsar, etc >, 
by="SPECSHOR,BONE"]

Your SPECSHOR and BONE names will be in your result alongside the results of 
the <whatever ...>

Or try package plyr which does this sort of thing too.  And sqldf may be 
better if you know SQL and prefer it.  There are actually zillions of ways 
to do it : by(), doBy() etc etc

If you get your code working the way its constructed currently,  its going 
to be very slow, because of those "==".   data.table doesn't do that and is 
pretty fast for this kind of thing. You might find that plyr is easier to 
use and more flexible though if speed isn't an issue,  depending on exactly 
what you want to do.

Whichever way you decide,  consider voting on crantastic for the package you 
end up using,  and that may be a quick and easy way for you to help new R 
users in the future, and help us all by reducing the r-help traffic on the 
same subject over and over again.

Note that plyr is the 2nd spot on crantastic,  it would have solved your 
problem without needing to write that code.  If you check crantastic first 
and make sure you're aware of popular packages, it might avoid getting stuck 
in this way again.  It only works if users contribute to it though.


"Ivan Calandra" <ivan.calandra at uni-hamburg.de> wrote in message 
news:4B587CDD.4070209 at uni-hamburg.de...