R script works fine.

Hopefulle completly functiona R script.