Algorithms and R code for environmental statistics