Let’s learn markdown by editing the README.md
on github.com for convenience. A README.md file can be added to every folder in a repository, and they are automatically displayed when the repository is opened on github.com
The README.md
is in markdown, simple syntax for conversion to HTML. .md
is a kind of text file, so you only need a text editor to read it. If you were editing this on your computer, you could do this right in RStudio, which has a built-in text editor. (You could also do it in another text editor program, but RStudio is convenient). Copy-paste the following into your README.md
:
# my-project
Playing with [Data Carpentry at UC Merced - Yosemite](https://snacktavish.github.io/2017-08-17-Yosemite/).
## Introduction
This repository demonstrates **software** and _formats_:
1. **Git**
1. **Github**
1. _Markdown_
1. _Rmarkdown_
## Conclusion
![](https://octodex.github.com/images/labtocat.png)
Now click on the Preview button to see the markdown rendered as HTML.
Notice the syntax for:
1.
, 1.
#
, ##
[](http://...)
![](http://...)
_word_
**word**
There are some good cheatsheets to get you started, and here is one built into RStudio:
See Mastering Markdown · GitHub Guides and add some more personalized content to the README of your own, like a bulleted list or blockquote. For on the fly rendering, the atom text editor is good.
Have a look through the repo on github.com to see the updates you’ve made, and notice that it renders below the files in the repo. This is a unique trait of README.md
Back in RStudio, let’s create a new Rmarkdown file, which allows us to weave markdown text with chunks of R code to be evaluated and output content like tables and plots.
File -> New File -> Rmarkdown… -> Document of output format HTML, OK.
You can give it a Title of “My Project”. After you click OK, most importantly File -> Save as index
(which will get named with the filename extension index.Rmd
).
Some initial text is already provided for you. Let’s go ahead and “Knit HTML”.
Notice how the markdown is rendered similar to as before + R code chunks are surrounded by 3 backticks and {r LABEL}
. These are evaluated and return the output text in the case of summary(cars)
and the output plot in the case of plot(pressure)
.
Notice how the code plot(pressure)
is not shown in the HTML output because of the R code chunk option echo=FALSE
.
Before we continue exploring Rmarkdown, let’s sync this the .rmd and .html to github.com. Enter a message like “added index” and click on “Commit and Sync gh-pages”. This will update https://github.com/USER/my-project, and now you can also see your project website with a default index.html
viewable at http://USER.github.io/my-project
Were you hoping for an RStudio Cheatsheet? Here it is:
In github.com; we’ll walk through this together. Then, practice more; make changes to their repo, and to their neighbor’s.