Rename a single column in kable() table

Viewed 2041

All -

I feel like I'm overlooking a simple solution. Is there a way to rename a single column in a kable() table?

Example of the original table.

library(tidyverse) library(knitr) tbl <- tibble(first_point=c(1,2,3), Second=c(4,5,6), Third=c(7,8,9)) kable()

Table1

Example of the desired table. I would prefer to not have to specify the "Second" and "Third" column names.

kable(tbl, col.names=c("First","Second","Third")

Table2

EDIT:

Thanks to everyone for their suggestions. I used @bouncyball's simple but effective tactic of automatically adding the column names for the other columns rather than manually including them when changing a single column. I didn't even consider that route. kable(tbl, col.names = c("First", names(tbl)[-1]))

0 Answers
Related