我想知道它是否可能反轉color_bar命令的大小formattable,例如:
library(formattable)
df = data.frame(Ranking = c(1, 2, 3, 4, 5, 8, 10))
formattable(df, list(Ranking = color_bar("red")))
我的表結果是:

是否有可能獲得數量最多的條形和數量1最短的條形10?我有一Ranking列1數字是最好的排名。
編輯1
其他對我有用的解決方案是省略或洗掉color_bar.
編輯2:
其他問題:如何將標題居中?
我的代碼:
formattable(df, align =c("c"), list(Ranking= color_bar("red")))
uj5u.com熱心網友回復:
試試這個解決方案:
```{r, include=FALSE, warning=FALSE}
library(formattable)
InvProp = function(x) (1.05 - ((x) / (max(x)))) #inverse proportion
#make our formattable
df = data.frame(" " = c(1, 2, 3, 4, 5, 8, 10, 15), check.names=FALSE)
table2 <- formattable(df, list(" " = color_bar("red", InvProp)))
```
#you can modify title style with html and css, as you wish
<center>
<caption>My formattable</caption>
</center>
`r table2`

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/368711.html
上一篇:找出有多少df1在df2中不可用
下一篇:查找指定值范圍內的最高值
