add type argument to R function