How do I print data frames in for loop without using print function? #6033
Answered
by
mcanouil
barisguven
asked this question in
Q&A
-
DescriptionI would like to print data frames generated in for loop as shown below. But Quarto does not print them neither when code chunk is run individually nor the qmd file is knitted to a html file. My objective is to get the data frames printed nicely as in kable style so that I can avoid using print function, which does not generate equally nice outcome. ---
title: "testing data frame printing in for loop"
format:
html:
df-print: kable
---
```{r}
columns <- c("mpg", "cyl", "disp", "hp")
mtcars[1:5, columns]
for (column in columns){
mtcars[1:5, column]
}
``` |
Beta Was this translation helpful? Give feedback.
Answered by
mcanouil
Jun 26, 2023
Replies: 1 comment 3 replies
-
You have to use (in your case) kable + print. See: |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
barisguven
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to use (in your case) kable + print.
If you don't print the content of the loop, there is no way you get a display out of it (this is not limited to Quarto).
See: