Update distributions.r

Tidied up R code made it more straight forward