adapted r script

0 indexing