# create test input arguments
set.seed(20161221)
n <- 5
a <- sample(letters, n)
b <- sample(letters, n)
w <- runif(n, min = -5, max = 50) * 1e+5
y <- runif(n, min = -25, max = 40) / 1e+3
z <- runif(n, min = -5, max = 100)
x <- data.frame(z, b, y, a, w, stringsAsFactors = FALSE)
# format different objects
print(x)
format_engr(x)
format_engr(x, sigdig = 3)
format_engr(x, sigdig = c(3, 4, 5))
format_engr(y, 2) # numeric vector
format_engr(n, 3) # numeric scalar
# using base R data sets
format_engr(DNase[1:10, ], sigdig = 4)
format_engr(mtcars[1:5, 1:5], sigdig = c(3, 0, 0, 0, 3))
format_engr(CO2[1:5,], 3)
## Not run:
# format_engr(a) # non-numeric, produces an error## End(Not run)
Run the code above in your browser using DataLab