Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- round2 = function(x, n) {
- posneg = sign(x)
- z = abs(x)*10^n
- z = z + 0.5
- z = trunc(z)
- z = z/10^n
- z*posneg
- }
- round2((-10:10)+0.005,2)
- sessionInfo()
- R version 3.5.0 (2018-04-23)
- Platform: x86_64-w64-mingw32/x64 (64-bit)
- Running under: Windows 7 x64 (build 7601) Service Pack 1
- Matrix products: default
- locale:
- [1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252
- [4] LC_NUMERIC=C LC_TIME=Dutch_Netherlands.1252
- attached base packages:
- [1] stats graphics grDevices datasets utils methods base
- other attached packages:
- [1] ggplot2_3.0.0 dplyr_0.7.6
- loaded via a namespace (and not attached):
- [1] Rcpp_0.12.18 withr_2.1.2 crayon_1.3.4 assertthat_0.2.0 plyr_1.8.4 grid_3.5.0 R6_2.2.2
- [8] gtable_0.2.0 magrittr_1.5 scales_0.5.0 pillar_1.3.0 rlang_0.2.1 lazyeval_0.2.1 rstudioapi_0.7
- [15] bindrcpp_0.2.2 tools_3.5.0 glue_1.3.0 munsell_0.5.0 purrr_0.2.5 yaml_2.2.0 compiler_3.5.0
- [22] colorspace_1.3-2 pkgconfig_2.0.1 bindr_0.1.1 tidyselect_0.2.4 tibble_1.4.2
Add Comment
Please, Sign In to add comment