Working R code for counting
Turn R code into a function
Function correction
Initialization of R shell script