converting scripts to an R package