x = rnorm(1e5)
x[sample(1e5, 1e4, TRUE)] = NA
# Dumb function telling the number of NA values
tell_na = function(x) message("x contains ", fsignif(sum(is.na(x))), " NA values.")
tell_na(x)
# Some differences with signif:
show_diff = function(x, d = 2) cat("signif(x, ", d, ") -> ", signif(x, d),
" vs fsignif(x, ", d, ") -> ",
fsignif(x, d), "\n", sep = "")
# Main difference is for large numbers
show_diff(95123.125)
show_diff(95123.125, 7)
# Identical for small numbers
show_diff(pi / 500)
Run the code above in your browser using DataLab