Last active
May 14, 2017 22:44
-
-
Save trinker/b370fad009dd85d351e4a5f765b24d18 to your computer and use it in GitHub Desktop.
formattable_example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p_load(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 | |
## Ticker Name Value Change | |
## 1 Dow Jones 15,988.08 -2.39% | |
## 2 S&P 500 1,880.33 -2.16% | |
## 3 Technology NA 2.10% | |
## 4 IBM IBM 130.00 -2.19% | |
## 5 AAPL Apple 97.05 -2.48% | |
## 6 MSFT Microsoft 50.99 -3.99% | |
formattable(DF, list( | |
Name=formatter( | |
"span", | |
style = x ~ ifelse(x == "Technology", | |
style(font.weight = "bold"), NA)), | |
Value = color_tile("lightblue", "pink"), | |
Change = formatter( | |
"span", | |
style = x ~ style(color = ifelse(x < 0 , "red", "green")), | |
x ~ icontext(ifelse(x < 0, "remove-circle", "ok-circle"), x))) | |
) |
Author
trinker
commented
Apr 16, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment