For example if my data frame was:
exampledf <- data.frame(column = c("exampletext1", "exampletext2", "exmapletext3"))
I would like the first page to have "exampletext1", the second page to have "exampletext2", etc.
\pagebreak works:
```{r, echo=FALSE}; exampledf[1,]```
\pagebreak
```{r, echo=FALSE} exampledf[2,]```
But my data frame is too large to make it practical.
I really need to loop through all my values:
for(i in 1:NROW(exampledf)) {
single <- exampledf[i]
strwrap(single, 70))
}
It's a weird question I realize.
You can put \\newpage inside the cat function to add a page break after each iteration of the loop. The chunk also needs to have the parameter results="asis". For example, does something like this work for you:
```{r echo=FALSE, results="asis", warning=FALSE}
library(xtable)
exampledf <- data.frame(column = c("exampletext1", "exampletext2", "exmapletext3"))
for (i in 1:nrow(exampledf)) {
# Just added this as another way of displaying a row of data
print(xtable(exampledf[i, , drop=FALSE]), comment=FALSE)
print(strwrap(exampledf[i,], 70))
cat("\n\\newpage\n")
}
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With