如何remove/change flextable 中的十进制总和值
How to remove/change decimal sum value in flextable
我设法根据以下代码创建了一个 flextable。
opleiding1 到 4 中使用的数据看起来有点像这样:0, 0, 1, 7, 3, 7, 0
t7 <- data.frame(df$opleiding.1.[df$startvraag=="Ja"],
df$opleiding.2.[df$startvraag=="Ja"],
df$opleiding.3.[df$startvraag=="Ja"],
df$opleiding.4.[df$startvraag=="Ja"]
)
t7 <- data.frame(aantal=(apply(t7, 2, sum))) %>% round(digits = 0)
rownames(t7) <- c("hbo, universitair", "mbo, vwo, havo", "vmbo/mavo", "onbekend")
t7
使用以下代码创建 flextable:
t7 <- xtable(t7)
ft7 <- t7 %>% xtable_to_flextable() %>%
fontsize(part = "header", size = 20) %>%
fontsize(part = "body", size = 18) %>%
align_text_col(align = "left") %>%
align_nottext_col(align = "center") %>%
width(width = 2.3) %>%
width(j = 1, width = 2.0) %>%
height_all(height = .5) %>%
border_inner(border = std_border) %>%
font(fontname = "Open Sans") %>%
color(part = "header", color = d) %>%
ft7
这给了我一个 flextable,除了显示 here. I've looked for possible solutions but nothing seems to work. It looks like the decimal is added when converting the table to an flextable. When I run the previous code (mentions on top) it does not return with any decimals as shown here 的小数点外,它和我想要的一样。希望有人能帮我解决这个问题。
我认为这是因为您的 aantal
列的类型是 double,这意味着它包含 real 值。您可以在创建 data.frame.
时将其类型更改为 integer
试试这个
t7 <- data.frame(aantal=(apply(t7, 2, sum))) %>%
round(digits = 0) %>%
mutate(aantal = as.integer(aantal))
我设法根据以下代码创建了一个 flextable。 opleiding1 到 4 中使用的数据看起来有点像这样:0, 0, 1, 7, 3, 7, 0
t7 <- data.frame(df$opleiding.1.[df$startvraag=="Ja"],
df$opleiding.2.[df$startvraag=="Ja"],
df$opleiding.3.[df$startvraag=="Ja"],
df$opleiding.4.[df$startvraag=="Ja"]
)
t7 <- data.frame(aantal=(apply(t7, 2, sum))) %>% round(digits = 0)
rownames(t7) <- c("hbo, universitair", "mbo, vwo, havo", "vmbo/mavo", "onbekend")
t7
使用以下代码创建 flextable:
t7 <- xtable(t7)
ft7 <- t7 %>% xtable_to_flextable() %>%
fontsize(part = "header", size = 20) %>%
fontsize(part = "body", size = 18) %>%
align_text_col(align = "left") %>%
align_nottext_col(align = "center") %>%
width(width = 2.3) %>%
width(j = 1, width = 2.0) %>%
height_all(height = .5) %>%
border_inner(border = std_border) %>%
font(fontname = "Open Sans") %>%
color(part = "header", color = d) %>%
ft7
这给了我一个 flextable,除了显示 here. I've looked for possible solutions but nothing seems to work. It looks like the decimal is added when converting the table to an flextable. When I run the previous code (mentions on top) it does not return with any decimals as shown here 的小数点外,它和我想要的一样。希望有人能帮我解决这个问题。
我认为这是因为您的 aantal
列的类型是 double,这意味着它包含 real 值。您可以在创建 data.frame.
试试这个
t7 <- data.frame(aantal=(apply(t7, 2, sum))) %>%
round(digits = 0) %>%
mutate(aantal = as.integer(aantal))