loading...

Fast version of rounding (when vector size >= 50000). ceiling_() takes a single numeric argument x and returns a numeric vector containing the smallest integers not less than the corresponding elements of x. It is similar to ceiling().

floor_() takes a single numeric argument x and returns a numeric vector containing the largest integers not greater than the corresponding elements of x. It is similar to floor().

trunc_() takes a single numeric argument x and returns a numeric vector containing the integers formed by truncating the values in x toward 0. It is similar to trunc().

round_() rounds the values in its first argument to the specified number of decimal places (default 0). See 'Details' about "round to even" in round() when rounding off a 5.

signif_() rounds the values in its first argument to the specified number of significant digits.

ceiling_(x, para = 50000L)

floor_(x, para = 50000L)

trunc_(x, para = 50000L)

round_(x, digits = 0L, para = 50000L)

signif_(x, digits = 6L, para = 50000L)

Arguments

x

vector of numeric values

para

the minimum length of x to use parallel computation (50000 by default)

digits

integer indication the number of decimal places (round_()) or significant digits (signif_()) to be used. For round_(), negative values are allowed and indicate rounding to a power of ten (-2 means rounding to the nearest hundred), see round().

Value

A numeric vector, matrix, or data frame with the transformed values.

Details

They are not generic functions and do not process factor, Date, POSIXt, difftime, complex, or S4 objects (use base R equivalent function instead). Data frames are processed column-wise, providing each column is compatible. All attributes are preserved.

Examples

floor_(c(1.23, 4.56, -7.89))
#> [1]  1  4 -8