I would like to ensure that the numeric fields in my data table always show 4 decimal places. The numeric fields need to remain numeric fields.
Secondly, when exporting the data to CSV, the numeric fields should always export with 4 decimal places.
I have imported a large .csv data file. It contains both numeric and text fields. I would like this data to always be displayed with 4 decimal places in the data table.
Also when exporting the data, it must be exported with decimal places in tact.
Currently I have used the following code:
library(formattable)
data$OS_BALANCE <- formattable(data$OS_BALANCE, digits=5, format='f')
data$OS_ACCRUAL <- formattable(data$OS_ACCRUAL, digits=5, format='f')
But when I rename variable the formatting disappears.