more generalised R functions