Started R code to replace C#