Learning code for running distributed r