# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- library(DAAG) sapply( cuckoos, is.factor ) specname = levels( cuckoos$species ) ss = 0 ndf = 0 for( nam in specname ){ lgth = cuckoos$length[ cuckoos$species==nam ] ss = ss + sum( ( lgth - mean(lgth) )^2 ) ndf = ndf + length(lgth)-1 } sqrt( ss / ndf ) diffs = unlist( sapply( split( cuckoos$length, cuckoos$species ), function(x) x - mean(x) ) ) df = unlist( sapply( split( cuckoos$length, cuckoos$species ), function(x) length(x)-1 ) ) sqrt( sum( diffs^2 ) / sum(df) )