r - 使用 formattable 的更多样式问题
问题描述
在下表中,如何删除加拿大行和世界行之间的线?
另外,如何从列标题中删除粗体(即 1980、2019、Change)?
这与建议的链接不同,我想知道是否有以下形式的解决方案:
# Define styles
row_emphasis <- formatter("span", style = ~style("font.weight" = "bold", "font.size" = "18px"))
make_non_bold <- formatter("span", style = "font-style:italic; font-weight:normal")
# Apply styles
formattable(can_world_table, list(
area(row = 1) ~ row_emphasis,
# column headers # ~ make_non_bold
))
至于关于删除行之间的线的部分,下面的建议答案并没有解决我的问题。此代码在 Canada 和标题行之间添加了另一行:
row_emphasis <- formatter("span", style = ~style("font.weight" = "bold", "font.size" = "18px", "border-top: 1px solid green"))
library(tidyverse)
library(formattable)
target_year = 1980
current_year = 2019
can_target = 20.464
can2019 = 37.786
world_target = 6123
world2019 = 7456
can_change <- (can2019 - can_target) / can_target
world_change <- (world2019 - world_target) / world_target
can_world_table <- tibble(
region = c("Canada", "World"),
ty = c(round(can_target, digits = 0), round(world_target, digits = -2)),
cy = c(can2019, round(world2019, digits = -2)),
change = percent(c(can_change, world_change), 0)
) %>%
set_names(c("", target_year, current_year, "Change"))
can_world_table
can_world_table <- tibble(
region = c("Canada", "World"),
ty = c(can_target, format(round(world_target, digits = -2), big.mark = ",")),
cy = c(can2019, format(round(world2019, digits = -2), big.mark = ",")),
change = percent(c(can_change, world_change), 0)
) %>%
set_names(c(" ", target_year, current_year, "Change"))
row_emphasis <- formatter("span", style = ~style("font.weight" = "bold", "font.size" = "18px"))
formattable(can_world_table, list(
area(row = 1) ~ row_emphasis
))
解决方案
推荐阅读
- google-apps-script - 为 Google 表单条目添加批准步骤 -> Google Sheet/Doc
- yarnpkg - 带有纱线浆果的 CLI 凹凸版本号
- sql - 当我尝试在 FROM 之后重命名表时,为什么会出现错误?
- design-by-contract - 使用“按合同设计”的好处
- react-native - Visual Studio Code 和 React-Native 的代码分析
- sql - 从正则表达式 substr 更新值
- string - R中的字符串正则表达式格式分析
- python - 构建 SQL 字符串时数据框的 Python For 循环采用标题行
- bep20 - 如何清除 BEP20 令牌创建错误
- encryption - 如何在 AES 加密(Arduino)中手动设置 Key 和 IV