Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 knitr 中实现 shell 命令并在 knitted pdf 文档中显示输出,如下所示:
```{r shell commands, engine="sh"} wc -wlmc en_US.blogs.txt ```
我不确定这是否正在评估,因为没有输出。
刚刚意识到我可以用 system() 调用它,它将打印到设备!所以,
system("wc -l en_US.blogs.txt")
将打印到显示屏。
使用 intern=TRUE 将 system() 的结果作为字符向量返回,然后 cat 与过去并折叠。例子。
x <- 系统(“树”,实习生=真)
猫(粘贴(x,折叠=“\ n”))
使用 knitr 在输出文档中放置工作目录树。