This utility method can be used as a format function when converting trees to a data.frame

FormatPercent(x, digits = 2, format = "f", ...)

Arguments

x

A number

digits

The number of digits to print

format

The format to use

...

Any other argument passed to formatC

Value

A string corresponding to x, suitable for printing

See also

formatC

Examples

data(acme)
print(acme, prob = acme$Get("p", format = FormatPercent))
#>                           levelName     prob
#> 1  Acme Inc.                                
#> 2   ¦--Accounting                           
#> 3   ¦   ¦--New Software              50.00 %
#> 4   ¦   °--New Accounting Standards  75.00 %
#> 5   ¦--Research                             
#> 6   ¦   ¦--New Product Line          25.00 %
#> 7   ¦   °--New Labs                  90.00 %
#> 8   °--IT                                   
#> 9       ¦--Outsource                 20.00 %
#> 10      ¦--Go agile                   5.00 %
#> 11      °--Switch to R              100.00 %