add R code to nplcm work