简体   繁体   中英

knitr: where is the output from example(help=knitr)?

With a chunk like the following, why is the output from the example() call not appearing in the output for me? Have I missed something obvious?

```{r}
require(knitr)
2+2
help(package='knitr')
```

I see "## 4" in the output, but not the help() output.

Thanks, Stephen

help(package='knitr') returns an object of the class packageInfo , and print.packageInfo() shows the formatted version of this object in a temp file via file.show() , which does not write anything to stdout() , so there is no way to capture the output.

You can write the help info into stdout manually using format() + cat() :

cat(format(help(package='knitr')), sep = '\n')

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM