Clean R code

Used formatR::tidy_source with 2 indent spacing, code needs to be checked it runs ok