I was wondering if there is a way to customize
round in R such that if one inputs non-numerics (ex.
round would just output the non-numeric as it is but just round the other numeric input?
Here is what I tried with no success:
a = c(.56789, "No", .87542) ## round numerics but just output the non-numeric roundif <- function(x, digits) if(any(!is.numeric(x))) x else round(x, digits) roundif(a, 2)