added comments to R codes