0

This might look like a simple question, and it probably is.

I have a dataset with 43 species and 24 environmental variables, for which I would like to calculate the mean value +/- CI 95% for each environmental variables for each species.

I figured out how to calculate the mean +/- CI 95% for one species and one environmental variable. But how to form a data frame (43 x 24) with all the values... I don't want to do it one by one...

ci.mean(tapply(allbryo$prep_anne, allbryo$Myl_ano , mean))

I suppose it's pretty simple, but I am new in R. Thank you!

Tung
  • 26,371
  • 7
  • 91
  • 115
MelinaG
  • 11
  • Check out the [split-apply-combine](http://stat545.com/block024_group-nest-split-map.html) functionalities behind `dplyr`, this should fairly directly address the issue you face – zack Jun 29 '18 at 14:59
  • Please share sample of your data so others can help. See more here https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1 – Tung Jun 29 '18 at 18:18
  • @Tung, here is an example of my data. data = matrix(1:12, ncol = 4) colnames(data)=c("spe1", "spe2","env1","env2") data=data.frame(data) mean(tapply(data$env1, data$spe1 , mean)) As you can see, I am able to calculate one mean, but, I want to do it for each combination of species and environmental variables. – MelinaG Jul 03 '18 at 14:06
  • @MelinaG: please add those to your question – Tung Jul 03 '18 at 15:35

0 Answers0