Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate README.md from README.Rmd for R package?

Tags:

r

roxygen2

cran

Inspecting dplyr shows there's both a README.md file and a README.Rmd file.

In the .md file, it says

README.md is generated from README.Rmd. Please edit that file

It's easy enough to create the .Rmd file, but how then is the .md file generated? Is it using roxygen2 or is there some terminal command (or something else)?

like image 568
stevec Avatar asked May 29 '19 10:05

stevec


People also ask

How do I create a README.md file in R?

In your repository on GitHub click on the green Add a README button. Now write a short description of your project in the <> Edit new file section and then click on the green Commit new file button. You should now see the README.md file listed in your repository.

Does README use Markdown?

Markdown language is used to write README[^readme. [^1]: A lightweight markup language (LML), also. It is designed to be easy to write using any.


1 Answers

Simply set output: github_document in the yaml at the top of the .Rmd and click knit.

Here's a small but complete RMarkdown document as an example:

---
output: github_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document that generates a github readme.md file.

```{r}
summary(iris)
```

Then simply click 'knit' like so:

enter image description here

Note:

  • for markdown document that is strictly 'markdown' (as opposed to github flavored markdown), use output: md_document instead (but if it's for a github readme, you'll most likely want the github flavored version)
like image 132
stevec Avatar answered Oct 07 '22 10:10

stevec