Zapsmall.RdPut to zero values "close" to zero.
# S3 method for default Zapsmall(x, digits = getOption("digits"), ...) # S3 method for data.frame Zapsmall(x, digits = getOption("digits"), except = NULL, ...)
| x | A |
|---|---|
| digits | Integer indicating the precision to be used. |
| except | Indices of columns not to be zapped (if any). |
| ... | Arguments for future expansion. |
This function "extends" to data.frame objects function zapsmall from the package base.
The method for class data.frame 'zaps' values close to zero occurring in columns of x. Argument except can be used to prevent specific columns from being zapped.
The default method is a bare copy of the original function from package base.
An object of the same class of x, with values "close" to zero zapped to zero.
The original function zapsmall from package base.
# Create a test data frame with columns containing # values of different orders of magnitude: data <- data.frame(a = pi*10^(-8:1), b = c(rep(1000,8), c(1E-5, 1E-6))) # Print on screen the test data frame: data#> a b #> 1 3.141593e-08 1e+03 #> 2 3.141593e-07 1e+03 #> 3 3.141593e-06 1e+03 #> 4 3.141593e-05 1e+03 #> 5 3.141593e-04 1e+03 #> 6 3.141593e-03 1e+03 #> 7 3.141593e-02 1e+03 #> 8 3.141593e-01 1e+03 #> 9 3.141593e+00 1e-05 #> 10 3.141593e+01 1e-06# Compare with its zapped version: Zapsmall(data)#> a b #> 1 0.000000 1000 #> 2 0.000000 1000 #> 3 0.000003 1000 #> 4 0.000031 1000 #> 5 0.000314 1000 #> 6 0.003142 1000 #> 7 0.031416 1000 #> 8 0.314159 1000 #> 9 3.141593 0 #> 10 31.415927 0