Applies formatting to an object to align it appropriately.
For numerics, strictly rounds to d decimal places and
lines up the decimal by adding appropriate whitespace. The use of d
will be taken as the exact number of decimal places. Many other number formatting
functions take arguments as "suggestions" only (e.g. options("digits")) or
use multiple ways of defining length of output
(e.g. significant figures and decimal places concurrently)
justify(x, ...) # S3 method for numeric justify(x, d = 3, ...) # S3 method for character justify(x, align = "left", na.rm = TRUE, ...) # S3 method for logical justify(x, form = "short", case = "upper", align = "left", na.rm = TRUE, ...) # S3 method for factor justify(x, ..., numeric = F) # S3 method for default justify(x, ...)
| x | object to be justified |
|---|---|
| ... | further arguments passed to or from other methods |
| d | explicit number of decimal places. |
| align |
|
| na.rm | should |
| form | should logical be printed in |
| case | should output be |
| numeric | for factors, should the underlying numeric reference be used,
or the level (if |
#> [1] " 5.68" " 8,132.49" " -111,411.03" " 0.76" #> [5] " 46,936,103.02" " -130,832.74" " -0.01" " 1,081.24" #> [9] " -69,125.80" " -46,916.33" " -0.01" " 0.59" #> [13] " 7.27" " 19,753.88" " 64.63" " 32.33" #> [17] " 43,475.90" "-15,624,839.39" " -0.58" " 1.21" #> [21] " -54,379.98" " 967.72" " 5,840.75" " -26,242.59" #> [25] " 0.07" " -418,976.08" " 93,076.37" "-42,476,226.63" #> [29] " 41,217,621.35" " 49.71" " 163.51" " -7.95" #> [33] " 0.25" " -1,170.64" " -75.61" " -207,660.15" #> [37] " 0.15" " -67,467.41" " 0.00" " 29.10" #> [41] " 1,689,438.12" " 3.49" " 4,042.99" " 3.70" #> [45] " 5,009.96" " 0.81" " 12,673,385.60" " -1,516.23" #> [49] " -1,163.14" " 2.71" " 214.91" " -27.15" #> [53] " -0.02" " 405.33" " -9.83" " 0.01" #> [57] " 19.75" " -731.26" " -1,107,455.52" " 33.56" #> [61] " 624.88" " -8,418.18" " 2.93" " -6.73" #> [65] " 446.03" "-12,479,554.05" " -3.09" " -0.68" #> [69] " 19,477.72" " -0.03" " 84,654,793.09" " -0.11" #> [73] " -424.56" " 2,242,603.90" " 99,912.58" " -2.07" #> [77] " 2,399.08" " 1,215,574.67" " 0.00" " 493.79" #> [81] " -343,515.47" " 1,236,402.09" " -62.13" " -1.43" #> [85] " -108.26" " 34,610.78" " -684.21" " -23,257.09" #> [89] " -1,208.24" " 2,016,947.26" " -62,445.97" " 3,104,453.19" #> [93] " -0.01" " 5,727,581.11" "-37,554,419.17" " 971.32" #> [97] " 6.98" " 290,887.78" " 4,701.31" " 11,493.47"set.seed(1) all_cols <- colours() all_cols <- unique(gsub("[0-9]", "", all_cols)) smp_cols <- sample(all_cols, 20) justify(smp_cols, align = "centre")#> [1] "lightgoldenrod" " slategray " " dimgrey " " cadetblue " #> [5] " goldenrod " " maroon " " darkblue " " orchid " #> [9] " lightsalmon " " bisque " " lightpink " "lightslategrey" #> [13] "darkslategrey " " orangered " "palevioletred " " navyblue " #> [17] " snow " " darkseagreen " " tomato " " mediumpurple "#> [1] "T" "F" " "justify(x, "long", "lower", "right")#> [1] " true" "false" " "justify(x, form = "long", align = "centre")#> [1] "TRUE " "FALSE" " "justify(x, form = "numeric")#> [1] "1" "0" " "justify(x, na.rm = TRUE)#> [1] "T" "F" " "