I know from Loop in R markdown that the asis
parameter in a markdown chunk will print the output of a loop. I want to render the same designed table for several variables and can't seem to figure out how to do that when using knitr
. In this example, I want to see three tables, each with one row of mtcars
.
---
title: "Untitled"
author: "Matt"
date: '2022-08-13'
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(kableExtra)
library(knitr)
```
```{r, results = 'asis'}
for( i in 1:3 ){
knitr::kable( mtcars[i,] ,
caption = i ) %>%
kable_paper( "hover" , full_width = F )
}
```