Skip to content

Instantly share code, notes, and snippets.

@JoeJoe1313
Forked from JoshuaTPierce/RMD_and_GitHub.docx
Created January 16, 2023 20:19
Show Gist options
  • Save JoeJoe1313/5a57303545ce1af5ea3e38a11d36d79d to your computer and use it in GitHub Desktop.
Save JoeJoe1313/5a57303545ce1af5ea3e38a11d36d79d to your computer and use it in GitHub Desktop.
Creating and Pushing a R-Markdown Document to Github (including graphs)
Go to github
Create new repository [don't need to initialize with the readme (can add later)]
Go to R Studio
File -> New Project -> Version Control -> Git
Ctrl+V repository URL from GitHub
File -> New -> Markdown, enter Title, etc.
In the Markdown window, change "output=html_document" to "output=github_document"
Knit the document for the first time, will prompt you to save
Save as Title.rmd
In the "git" tab of the R studio Environment window, you will notice that the knit produced:
Title.rproj
Title.rmd
Title.md
Changing output to github_document makes the original .rmd knit to .md so the code can be rendered when pushed to Git.
In the Git window, check the box to stage Title.md [NOT .rmd]
Click "commit," add comment.
Click the green arrow to push to GitHub.
Go to GitHub, refresh the repository, and the markdown document with rendered code will be there
IF YOUR DOCUMENT INCLUDES GRAPHS:
When you knit, a new file will save to the Git window, called Title.docs
When you commit, check the box to stage the .docs in addition to the .md document.
This will commit the graphs as a separate file to the repository,
although the graphics will automatically pull in to the markdown document when rendered.
@JoeJoe1313
Copy link
Author

rmarkdown::run("your-rmd-document.Rmd")

@JoeJoe1313
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment