在格式 table 包生成的 table 的列之一中生成颜色的问题
The problem with producing the colour in one of the column of the table produced by the formattable package
我之前应用了这段代码,结果并不完全符合预期,因为 matching_probability 部分没有显示彩色方块。
我无法添加图像,否则我会显示。
formattable(df,
align = c("l","c","c","c","c","c","r"),
list(`Locus_number` = formatter(
"span", style = ~ style(color = "grey",font.weight = "bold")),
`PIC`= color_tile(customGreen, customGreen0),
`Matchin_Probability`= color_tile('white', 'orange'),
`Power_of_Discrimination`= color_tile(customGreen, customGreen0),
`Power_of_Exclusion`= color_tile(customGreen, customGreen0),
`Paternity_Index` = color_bar(customRed)
))
我以前遇到过同样的问题,可能你在特定列中有一些 inf 值,只需将其替换为 0 或 NA
df[mapply(is.infinite, df)] <- NA
我之前应用了这段代码,结果并不完全符合预期,因为 matching_probability 部分没有显示彩色方块。 我无法添加图像,否则我会显示。
formattable(df,
align = c("l","c","c","c","c","c","r"),
list(`Locus_number` = formatter(
"span", style = ~ style(color = "grey",font.weight = "bold")),
`PIC`= color_tile(customGreen, customGreen0),
`Matchin_Probability`= color_tile('white', 'orange'),
`Power_of_Discrimination`= color_tile(customGreen, customGreen0),
`Power_of_Exclusion`= color_tile(customGreen, customGreen0),
`Paternity_Index` = color_bar(customRed)
))
我以前遇到过同样的问题,可能你在特定列中有一些 inf 值,只需将其替换为 0 或 NA
df[mapply(is.infinite, df)] <- NA