Skip to Content
0
3 days ago

R-Visualizations problem in SAC - library formattable

54 Views

Hello!

I am trying to reproduce the coding example of https://www.magesblog.com/post/2016-01-19-formatting-table-output-in-r/.

The visualization problem which occurs when running the code is, that the formatting of the "arrow-up" and "arrow-down" icons isn't working. Basically the R-Interface of SAP Analytics Cloud should support the library formattable but for some reasons the visualization of the icons is not supported.

Do you have any suggestions?

See visualization and code below:

image.png

library(formattable)
DF <- data.frame(Ticker=c("", "", "", "IBM", "AAPL", "MSFT"),
                 Name=c("Dow Jones", "S&P 500", "Technology", 
                        "IBM", "Apple", "Microsoft"),
                 Value=accounting(c(15988.08, 1880.33, NA, 
                                    130.00, 97.05, 50.99)),
                 Change=percent(c(-0.0239, -0.0216, 0.021, 
                                  -0.0219, -0.0248, -0.0399)))
DF

formattable(DF, list(
  Name=formatter(
    "span",
    style = x ~ ifelse(x == "Technology", 
                       style(font.weight = "bold"), NA)),
  Value = color_tile("white", "orange"),
  Change = formatter(
    "span",
    style = x ~ style(color = ifelse(x < 0 , "red", "green")),
    x ~ icontext(ifelse(x < 0, "arrow-down", "arrow-up"), x)))
)

Attachments

image.png (4.5 kB)