gpt4 book ai didi

r - 如何从 kableExtra kbl 表中删除 NA?

转载 作者:行者123 更新时间:2023-12-02 02:23:45 27 4
gpt4 key购买 nike

当我运行这段代码时:

library(kableExtra)

table %>%
kbl(caption ="Table 3: Data for Difference Equation Estimation.",col.names = c("Location",
"Year",
"Price",
"Per Capita Quantity",
"$\\Delta{P}$",
"$\\Delta{Q}$")) %>%
kable_styling(full_width = F, position = "left")

我得到以下信息:

enter image description here

如何删除 NA?

最佳答案

knitr::kable()kableExtra::kbl() 的基础。如果您查看 knitr::kable() 的帮助文档,它说:

Missing values (NA) in the table are displayed as NA by default. If you want to display them with other characters, you can set the option knitr.kable.NA, e.g. options(knitr.kable.NA = '') to hide NA values.

因此你可以尝试:

options(knitr.kable.NA = '')

table %>%
kbl(caption = "Table 3: Data for Difference Equation Estimation.",
col.names = c("Location",
"Year",
"Price",
"Per Capita Quantity",
"$\\Delta{P}$",
"$\\Delta{Q}$")) %>%
kable_styling(full_width = F,
position = "left")

关于r - 如何从 kableExtra kbl 表中删除 NA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66028646/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com