如何在弹性表中保留字符列的(附加)空白?代码顺序
flextable(data.frame("temp" = c("Lore ips",
"dol sit")))
生成以下图像:
请注意“ips”和“sit”子文本如何在
data.frame
中对齐,但在弹性表中未对齐。
您可以使用函数将空格替换为
,如下所示:
library(flextable)
render_cell <- function(x) {
return(paste0("<td>", gsub(" ", " ", x), "</td>"))
}
ft <- flextable(
data.frame(
temp = c(render_cell("Lore ips"), render_cell("dol sit"))
)
)
ft