This is not an issue with accouting
function, it is more a matter of order of operation in the pipe.
as.integer()/100
is not a correct pipe step. You need to correctly isolate it using a function define before or using dot anonymous function, so that accounting
applies correctly on the result of this.
There are also special pipe-friendly operation in magrittr
for this kind of issue.
library(magrittr)
library(formattable)
accounting("39990" %>% as.integer()/100)
#> [1] 399.90
# Taking care of pipe operation precedence
"39990" %>% {as.integer(.)/100} %>% accounting()
#> [1] 399.90
# using special pipe operation from magrittr
"39990" %>% as.integer() %>% magrittr::divide_by(100) %>% accounting()
#> [1] 399.90
Created on 2018-06-06 by the reprex package (v0.2.0).
EDIT: the question is also on SO - @EconKid see Policies in FAQ