Fully packaged code for R