[英]How to use RStudio to write R Markdown files with Stata graphs?
The code below works for Stata commands and output but does not produce the graphs: 下面的代码适用于Stata命令和输出,但不生成图形:
---
title: "Stata and R Markdown (Windows)"
author: "Doug Hemken"
date: "July 2015"
output:
html_document:
toc: yes
---
```{r, echo=FALSE, message=FALSE}
require(knitr)
statapath <- "/Applications/Stata/StataSE.app/Contents/MacOS/stata-se"
opts_chunk$set(engine="stata", engine.path=statapath, comment="")
```
### Descriptive Statistics
A simple example.
```{r}
sysuse auto
summarize
```
```{r}
sysuse auto
twoway (scatter mpg weight)
```
Note that this is a follow-up of this question: 请注意,这是此问题的后续内容:
You need to export the graph and include an image link in the R Markdown as follows: 您需要导出图形,并在R Markdown中包含图像链接,如下所示:
```{stata, echo=1, results="hide"}
twoway (scatter mpg weight)
graph export "myscatter.svg", replace
```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.