fix R interface to cpp call