There's a generic function called knit_print
with methods for various classes; run methods("knit_print")
to see what they are with the packages you have loaded. If your final object (which probably has classes "tbl_df"
, "tbl"
, and "data.frame"
) has a class for which there's a knit_print
method, that's what it will use. Running example(knit_print)
will create a data.frame
method.
From the other answer, it appears that it was the printr
package which added a knit_print.data.frame
method. To work around this, you can use the render
chunk option, eg
```{r}
library(printr)
head(mtcars)
```
```{r render = print}
head(mtcars)
```
which yields this output:
After reading vi.nette('knit_print', package = 'knitr')
I discovered that in my case the cause was that I had blindly added library(printr)
in the preamble of my Rnw file, which produced formatted output (as in my second inserted image). When I commented out that line, the output was as you would see it in interacting with R in the console (as in the first image).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.