R- knitr:kable-如何显示不带列名的表? [英] R- knitr:kable - How to display table without column names?
本文介绍了R- knitr:kable-如何显示不带列名的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前,我具有以下数据帧(PS):
Currently, I have this data frame (PS):
我要显示此表的代码是:
My code to display this table is:
kable(PS) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
我想显示不带列名的表,如下所示:
I want to display the table without column names like this:
问题是
1)列名应为非空,并且尝试使用空名称将导致不支持的结果
1) The column names should be non-empty, and attempts to use empty names will have unsupported results
2)如果我转换数据框并删除列名,然后像这样使用kable:
2) If I convert the data frame and remove the column names and then use kable like this:
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
我也尝试了以下参数,但没有结果
I also tried the following parameter but with no results
kable(PS, col.names = NA)
可复制的示例:
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("$30K","$30K","Daily","50%","6,933","25%","ES")
AI <- data.frame(Statistics,Value);
kable(AI) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
推荐答案
根据所需的输出格式,您可以使用此类功能.对于pandoc:
Depending on your desired output format you could make use of such functions. For 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)
这篇关于R- knitr:kable-如何显示不带列名的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文