Converted scripts into R package