I am practicing data analysis using R programming. I want my files to be on github. I am unable to figure out why github is not showing the output of .rmd files.
我正在使用R编程进行数据分析。我希望我的文件在github上。我无法弄清楚为什么github没有显示.rmd文件的输出。
Here is the link to the file in my github repository Data Analysis Practice
这是我的github存储库数据分析实践中的文件的链接
I want the output including plots to be shown on github.
我希望包含绘图的输出显示在github上。
1 个解决方案
#1
26
Instead of:
output: html_document
make it:
output: rmarkdown::github_document
(assuming you have the latest rmarkdown installed which you should if you're using RStudio — which I suspect you are — and keep it updated or update packages regularly).
(假设您安装了最新的rmarkdown,如果您使用的是RStudio,我应该使用它 - 我怀疑您是 - 并保持更新或定期更新软件包)。
It will create Exploring_one_variable.md
and render the images as files.
它将创建Exploring_one_variable.md并将图像呈现为文件。
When you browse to that markdown file, the images will render.
当您浏览到该降价文件时,图像将呈现。
An alternative is to use:
另一种方法是使用:
output:
html_document:
keep_md: true
and it will render to both Exploring_one_variable.md
and Exploring_one_variable.html
so you'll have the best of both worlds without the local github-esque preview that the former provides.
它将呈现给Exploring_one_variable.md和Exploring_one_variable.html,这样你就可以在没有前者提供的本地github-esque预览的情况下充分利用这两个世界。
You can get fancier and put something like the following as the first code section in the Rmd:
您可以获得更高级的功能,并将以下内容作为Rmd中的第一个代码部分:
```{r, echo = FALSE}
knitr::opts_chunk$set(
fig.path = "README_figs/README-"
)
```
which will put the figures in a directory of your choosing.
这会将数字放在您选择的目录中。
You can see this in action here as the README.md
was generated with knitr
from the README.Rmd
in the same directory.
您可以在此处看到这一点,因为README.md是使用同一目录中README.Rmd的knitr生成的。
#1
26
Instead of:
output: html_document
make it:
output: rmarkdown::github_document
(assuming you have the latest rmarkdown installed which you should if you're using RStudio — which I suspect you are — and keep it updated or update packages regularly).
(假设您安装了最新的rmarkdown,如果您使用的是RStudio,我应该使用它 - 我怀疑您是 - 并保持更新或定期更新软件包)。
It will create Exploring_one_variable.md
and render the images as files.
它将创建Exploring_one_variable.md并将图像呈现为文件。
When you browse to that markdown file, the images will render.
当您浏览到该降价文件时,图像将呈现。
An alternative is to use:
另一种方法是使用:
output:
html_document:
keep_md: true
and it will render to both Exploring_one_variable.md
and Exploring_one_variable.html
so you'll have the best of both worlds without the local github-esque preview that the former provides.
它将呈现给Exploring_one_variable.md和Exploring_one_variable.html,这样你就可以在没有前者提供的本地github-esque预览的情况下充分利用这两个世界。
You can get fancier and put something like the following as the first code section in the Rmd:
您可以获得更高级的功能,并将以下内容作为Rmd中的第一个代码部分:
```{r, echo = FALSE}
knitr::opts_chunk$set(
fig.path = "README_figs/README-"
)
```
which will put the figures in a directory of your choosing.
这会将数字放在您选择的目录中。
You can see this in action here as the README.md
was generated with knitr
from the README.Rmd
in the same directory.
您可以在此处看到这一点,因为README.md是使用同一目录中README.Rmd的knitr生成的。