У меня следующий код в R:
(взят из https://cran.r -project.org / web / packages / formattable / vignettes / formattable-data-frame.html )
library(formattable)
sign_formatter <- formatter("span",
style = x ~ style(color = ifelse(x > 0, "green",
ifelse(x < 0, "red", "black"))) )
products <- data.frame(id = 1:5,
price = c(10, 15, 12, 8, 9),
rating = c(5, 4, 4, 3, 4),
market_share = percent(c(0.1, 0.12, 0.05, 0.03, 0.14)),
revenue = accounting(c(55000, 36400, 12000, -25000, 98100), digits = 0L),
profit = accounting(c(25300, 11500, -8200, -46000, 65000)))
formattable(products, list(
price = color_tile("transparent", "lightpink"),
rating = color_bar("lightgreen"),
market_share = color_bar("lightblue"),
revenue = sign_formatter,
profit = sign_formatter) )
Это печатает следующую таблицу
Как я могу повторить это в блоках данных или что-то подобное