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

1

14

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)?

Fuchsia answered 29/5, 2019 at 10:24 Comment(0)
F
18

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)
Fuchsia answered 9/9, 2020 at 1:19 Comment(1)
Just for a non-RStudio alternative, use devtools::build_readme(). But, as the answer above mentions, you need to include output: github_document or the output with be html.Susurration

© 2022 - 2024 — McMap. All rights reserved.