Home > database >  generate tables in Rmarkdown
generate tables in Rmarkdown

Time:12-15

Hello I have problems to generate the tables correctly, instead of being under the code they go up to the beginning of the page as shown below:

enter image description here

The code that I use as an example is the following

{r,echo=FALSE,size="tiny",warning=FALSE,message=FALSE}

sample<-mtcars[1:4,1:3]

kbl(sample,booktabs=T) %>%
kable_styling(latex_options=c("striped"))

It prints the table correctly but the result is up to the top, what is the reason for this problem?

CodePudding user response:

Have you tried changing to echo = TRUE

{r,echo=TRUE,size="tiny",warning=FALSE,message=FALSE}
library(dplyr)
library(kableExtra)


sample<-mtcars[1:4,1:3]

kbl(sample,booktabs=T) %>%
kable_styling(latex_options=c("striped"))

enter image description here

CodePudding user response:

I ran you code and did not have the same issue.

I'm currently using Rstudio v1.5.1717 with R version 4.1.2

I ran your code as an R-Notebook as a "chunk":

{r,echo=FALSE,size="tiny",warning=FALSE,message=FALSE}

sample<-mtcars[1:4,1:3]

kbl(sample,booktabs=T) %>%
kable_styling(latex_options=c("striped"))
  • Related