[R-sig-eco] Reshape or Plyr solution
Bruce Miller
batsncats at gmail.com
Sun Apr 21 22:27:52 CEST 2013
Hi all,
I had several replies that provided a solution to my previous query.
Using plyr it seems to work (Thanks Dennis Murphy and Arun)
library(plyr)
ddply(DF, .(SPEC_CODE), mutate, RA = 10 * sum(AI)/sum(Time))
This one nearly works just need to invert the SumAI and Sum Survey time
so that SumAI/SumTime provides the correct answer.
res<- mutate(ddply(dat1,.(SPEC_CODE,Location_name),function(x) colSums(x[,-c(1:3,6)])),SumAIbySumST=Survey_Time/AI,Std.SumAIbySumST=10*SumAIbySumST)
Tnx all for the help,
Bruce
More information about the R-sig-ecology
mailing list