R- knitr:kable - 如何在没有列名的情况下显示 table?
R- knitr:kable - How to display table without column names?
目前,我有这个数据框(PS):
我显示此 table 的代码是:
kable(PS) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
我想显示没有像这样的列名称的 table:
问题是
1) 列名称不能为空,尝试使用空名称将产生不受支持的结果
2) 如果我转换数据框并删除列名,然后像这样使用 kable:
PS.mat <- as.matrix(PS)
colnames(PS.mat) <- NULL
kable(PS) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
我收到以下错误
Error in kable_info$colnames[[length(kable_info$colnames)]] : attempt to select less than one element in integerOneIndex
我也尝试了以下参数但没有结果
kable(PS, col.names = NA)
编辑 1:
一个可重现的例子:
if (!require(pacman)) install.packages("pacman")
p_load("lubridate","knitr","kableExtra","scales")
Statistics <- c("AUM",
"Minimum Managed Account Size",
"Liquidity",
"Average Margin / Equity",
"Roundturns / $ Million / Year",
"Incentive Fees",
"Instruments Traded")
Value <- c("K","K","Daily","50%","6,933","25%","ES")
AI <- data.frame(Statistics,Value);
kable(AI) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
根据您想要的输出格式,您可以使用这些功能。对于 pandoc:
x = kable(AI, format="pandoc") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
cat(x[3:9], sep="\n")
对于html:
x = kable(AI, format="html") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
gsub("<thead>.*</thead>", "", x)
目前,我有这个数据框(PS):
我显示此 table 的代码是:
kable(PS) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
我想显示没有像这样的列名称的 table:
问题是
1) 列名称不能为空,尝试使用空名称将产生不受支持的结果
2) 如果我转换数据框并删除列名,然后像这样使用 kable:
PS.mat <- as.matrix(PS)
colnames(PS.mat) <- NULL
kable(PS) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
我收到以下错误
Error in kable_info$colnames[[length(kable_info$colnames)]] : attempt to select less than one element in integerOneIndex
我也尝试了以下参数但没有结果
kable(PS, col.names = NA)
编辑 1:
一个可重现的例子:
if (!require(pacman)) install.packages("pacman")
p_load("lubridate","knitr","kableExtra","scales")
Statistics <- c("AUM",
"Minimum Managed Account Size",
"Liquidity",
"Average Margin / Equity",
"Roundturns / $ Million / Year",
"Incentive Fees",
"Instruments Traded")
Value <- c("K","K","Daily","50%","6,933","25%","ES")
AI <- data.frame(Statistics,Value);
kable(AI) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
根据您想要的输出格式,您可以使用这些功能。对于 pandoc:
x = kable(AI, format="pandoc") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
cat(x[3:9], sep="\n")
对于html:
x = kable(AI, format="html") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
gsub("<thead>.*</thead>", "", x)