R migrate functions
Clean up R functions from the plot script by moving to a function script.
Make sure handling of NA's are optimal!!
Clean up R functions from the plot script by moving to a function script.
Make sure handling of NA's are optimal!!