R code from Napo