Description Usage Arguments Details Value See Also Examples
Format numbers in the table so they are correct in Persian.
1 | KH.changeDecimal(DT, columns = c())
|
DT |
data.table. Numerical data required for changing the decimal point. |
columns |
string|number. Columns' names or numbers in the data to change. |
Decimal point in persian is different from that in English. This function replaces it so the decimal numbers are read correctly
DT data.table. All the decimal points in the given columns are replaced with Persian equivalent.
Other Utils: KH.ifNull
,
KH.roundAll
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | {
KH.changeDecimal(1.23)
#[1] "1٫23"
KH.changeDecimal(12.3)
#[1] "12٫3"
KH.changeDecimal('a.23')
#[1] "a.23"
KH.changeDecimal(c(1.23, 0.02))
#[1] "1٫23" "0٫02"
columns <- c('dep_x','arr_x')
input_file <- system.file("extdata", "input_file.csv", package = "KHanSUtils")
DT <- KH.loadCSV(input_file)
DT[, c('dep_x','arr_x') := list(dep_delay/10, arr_delay/10)]
DT
# year month day dep_delay arr_delay carrier origin dest air_time distance hour dep_x arr_x
# 1: 2014 1 1 14 13 AA JFK LAX 359 2475 9 1.4 1.3
# 2: 2014 10 31 1 -30 UA LGA IAH 201 1416 14 0.1 -3.0
# 3: 2014 1 1 -3 13 AA JFK LAX 363 2475 11 -0.3 1.3
# 4: 2014 10 31 -5 -14 UA EWR IAH 189 1400 8 -0.5 -1.4
# 5: 2014 1 1 2 9 AA JFK LAX 351 2475 19 0.2 0.9
# 6: 2014 10 31 -8 16 MQ LGA RDU 83 431 11 -0.8 1.6
# 7: 2014 1 1 -8 -26 AA LGA PBI 157 1035 7 -0.8 -2.6
# 8: 2014 10 31 -4 15 MQ LGA DTW 75 502 11 -0.4 1.5
# 9: 2014 1 1 2 1 AA JFK LAX 350 2475 13 0.2 0.1
#10: 2014 10 31 -5 1 MQ LGA SDF 110 659 8 -0.5 0.1
#11: 2014 1 1 4 0 AA EWR LAX 339 2454 18 0.4 0.0
KH.changeDecimal(DT, columns)
# year month day dep_delay arr_delay carrier origin dest air_time distance hour dep_x arr_x
# 1: 2014 1 1 14 13 AA JFK LAX 359 2475 9 1٫4 1٫3
# 2: 2014 10 31 1 -30 UA LGA IAH 201 1416 14 0٫1 -3
# 3: 2014 1 1 -3 13 AA JFK LAX 363 2475 11 -0.3 1٫3
# 4: 2014 10 31 -5 -14 UA EWR IAH 189 1400 8 -0.5 -1.4
# 5: 2014 1 1 2 9 AA JFK LAX 351 2475 19 0٫2 0٫9
# 6: 2014 10 31 -8 16 MQ LGA RDU 83 431 11 -0.8 1٫6
# 7: 2014 1 1 -8 -26 AA LGA PBI 157 1035 7 -0.8 -2.6
# 8: 2014 10 31 -4 15 MQ LGA DTW 75 502 11 -0.4 1٫5
# 9: 2014 1 1 2 1 AA JFK LAX 350 2475 13 0٫2 0٫1
#10: 2014 10 31 -5 1 MQ LGA SDF 110 659 8 -0.5 0٫1
#11: 2014 1 1 4 0 AA EWR LAX 339 2454 18 0٫4 0
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.