<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"> <pre>Caros amigos do R, na rotina abaixo gostaria de calcular além da média, o desvio padrão e o CV=(sd/mean). Como fazer estes cálculos?<br>## example with character variables and NAs
testDF <- data.frame(v1 = c(1,3,5,7,8,3,5,NA,4,5,7,9),
v2 = c(11,33,55,77,88,33,55,NA,44,55,77,99) )
by1 <- c("red","blue",1,2,NA,"big",1,2,"red",1,NA,12)
by2 <- c("wet","dry",99,95,NA,"damp",95,99,"red",99,NA,NA)
aggregate(x = testDF, by = list(by1, by2), FUN = "mean")
# and if you want to treat NAs as a group
fby1 <- factor(by1, exclude = "")
fby2 <- factor(by2, exclude = "")
aggregate(x = testDF, by = list(fby1, fby2), FUN = "mean")
</pre><br>FELIZ 2012 a todos os amigos e familiares da lista.<br><br><div>Edson Lira<br>Estatístico<br>Manaus-Amazonas</div></div></body></html>