add R implementation

I hope you may find this useful, and of course any feedback is highly welcomed.