我正在尝试更改下表中各种标题的字体大小。
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kable(dt) %>%
kable_styling(c("striped", "bordered")) %>%
add_header_above(c(" ", "Group 1" = 2, "Group 2" = 2, "Group 3" = 2)) %>%
add_header_above(c(" ", "Group 4" = 4, "Group 5" = 2)) %>%
add_header_above(c(" ", "Group 6" = 6))
来自上面代码的表格图片:
但是,我希望标题组6远大于组4和5,而组1,2,3再次较小。这可能吗?
除此之外,是否可以调用一个对象来命名“ Group6”标题,而不必键入字符串?
先谢谢您,
答案 0 :(得分:0)
为his post提供@Rene的信用,如何使用动态标签对通过public static void main(String[] args) {
// map which contains only upper case letters with random values
Map<Character, Integer> map = new HashMap<>();
for (int i = 0; i < 26; ++i){
// upper case A ascii value is 65, we start from 65
map.put((char)(65 + i), (int) (Math.random() * (10)));
}
// input values
String[] inputs = {"SUDHA", "kiran", "ANI34"};
boolean valid;
int sum;
for (int j = 0; j < inputs.length; ++j){
sum = 0;
valid = true;
for (int i = 0; i < inputs[j].length(); ++i){
// if char is not in map, it means that it is not uppercase letter
if (!map.containsKey(inputs[j].charAt(i))){
System.out.println("Sample output " + (j + 1) + ": Invalid Name: " + inputs[j]);
valid = false;
break;
}else{
sum += map.get(inputs[j].charAt(i));
}
}
if (valid){
System.out.println("Sample output " + (j + 1) + ": Your numerology no is: " + sum);
}
}
}
添加到表格顶部的行进行分组。
add_header_above()