kable_input not found when knitting using knitr and knitExtra

Viewed 3498

I'm brand new at R and I would like to make a neat table of my dataset using the packages kable and knitExtra in Rmarkdown. I'll try to explain the error through my code:

```{r, include=FALSE}
library(readxl); library(dplyr); library(kableExtra); library(knitr)
Froot <- read_excel("~/Documents/Project1/Fruit.xlsx")

knitr::kable(Froot[1:4])
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

In the above code, when I try to knit it returns this error:

Quitting from lines 37-39 (Project1.Rmd)

Error in kable_styling(bootstrap_options = c("striped", "hover", "condensed")) : argument "kable_input" is missing, with no default

Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> kable_styling

Execution halted

I notice the error is in the function "kable_styling", and so I attempted to solve the issue by just adding "kable_input", which turns the code into this:

```{r, include=FALSE}
library(readxl); library(dplyr); library(kableExtra); library(knitr)
Froot <- read_excel("~/Documents/Project1/Fruit.xlsx")

knitr::kable(Froot[1:4])
  kable_styling(kable_input, bootstrap_options = c("striped", "hover", "condensed"))

But when I knit, it tells me that function "kable_input" could not be found!!

Quitting from lines 37-39 (Project1.Rmd)

Error in kable_input() : could not find function "kable_input"

Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> kable_styling

Execution halted

Any fixes? I've tried googling it but I literally got no results.

1 Answers

@stefan is right, yout have to add the pipe %>% and also remove kable_input which he did in his comment. Also, you can remove include=FALSE from the chuck (this evaluates the code but doesn't show the result).

```{r}
library(readxl)
library(dplyr)
library(kableExtra)
library(knitr)

Froot <- read_excel("~/Documents/Project1/Fruit.xlsx")


knitr::kable(Froot)%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
```

This example works in my case:

knitr::kable(iris)%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
Related