tried in r, cant get to work effectively