0

I am using kableExtra to format tables in rmarkdown. In one of my dataframes I am obtaining a strange result...

ncol(Selected)
Selected%>%
kable("html",format.args = list(decimal.mark = ".", big.mark = ","),caption = "Variables description  and data cleaning and treatment summary") %>%
add_header_above(c(" " = 2, "Kolmogorov-Smirnov" = 2, "Kruskall-Wallis" = 2, "Wilcoxon  Test"= 2)) %>%
kable_styling()

The object Selected is a dataframe, with dimension (256;8)...

I got this:

[1] 8
Error in htmlTable_add_header_above(kable_input, header, bold, italic, : The new header row you provided has a different total number of columns with the original kable output.

What is wrong? By ncol, I confirmed the object Selected has 8 columns... Thanks in advance.

4

1 回答 1

2

此数据框具有行名称。kable 命令将行名计为列。算上这一点,它奏效了。

Selected%>%
kable("html",format.args = list(decimal.mark = ".", big.mark = ","),caption = "Variables description  and data cleaning and treatment summary") %>%
add_header_above(c(" " = 3, "Kolmogorov-Smirnov" = 2, "Kruskall-Wallis" = 2, "Wilcoxon  Test"= 2)) %>%
kable_styling()
于 2018-05-25T15:52:33.193 回答