Writing text/documents
Managing citations and bibliographies
Performing data analysis
Making figures and tables
Saving files for future use
Monitoring changes in documents
Collaborating and sharing with others
Combining into a deliverable (report, paper, presentation, etc.)
Writing text/documents
Managing citations and bibliographies
Performing data analysis
Making figures and tables
Saving files for future use
Monitoring changes in documents
Collaborating and sharing with others
Combining into a deliverable (report, paper, presentation, etc.)
A lot of copy-pasting
A lot of...
This is how I make my...
I have not used any MS Office products since 2011 (good riddance!)
This stuff is optional
R Markdown
, which can do all of this in one pipelinePlain text files: readable by both machines and humans
Focus entirely on the actual writing of the content instead of the formatting and aesthetics
Open Source: free, useable forever, often very small file size
.doc
file from Microsoft Word 1997?Automate and Minimize Errors, especially in repetitive processes
Can be used with version control (see below)
One day you will need to quit R, go do something else and return to your analysis the next day. One day you will be working on multiple analyses simultaneously that all use R and you want to keep them separate. One day you will need to bring data from the outside world into R and send numerical results and figures from R back out into the world. To handle these real life situations, you need to make two decisions: What about your analysis is "real", i.e. what will you save as your lasting record of what happened? Where does your analysis "live"?
- Hadley Wickham, R For Data Science
We've talked about .R
script files that let you "keep" commands
What about output? Must you save and copy/paste to MS Word? No!
R Markdown
file (.Rmd
) is the "real" part of your analysis, everything can live in this plain-text file!
Document text in markdown
R code
executed in "chunks"
Plots and tables generated from R code
Citations and bibliography automated with .bib
file
File -> New File -> R Markdown...
rticles
or xaringan
add neat templates)File -> New File -> R Markdown...
html
: renders a webpage, viewable in any browserpdf
: renders a PDF documentLaTeX
distribution to render (more on that soon)word
: create a Micosoft Word documentEntire document is written in a single file1 with three types of content:
YAML
header for metadata
Text of the document written with markdown
R
chunks for data analysis, plots, figures, tables, statistics, as necessary
1 The one exception is for managing bibliographies, this requires one additional .bib
file!
Top of a document contains the YAML
1 separated by three dashes ---
above and below
Contains the metadata of the document, such as:
title: "My Title"author: "Ryan Safner"date: "`r Sys.Date()`" # here I'm using R code to generate today's date!output: pdf_document
output
must be specified, everything else can be left blank, and other options can be added as necessary
In most cases, you can safely ignore other things in the yaml
until you are ready
1 YAML stands for "YAML Ain't Markup Language." Nerds love recursive acronyms.
title: Distributing Patronage^[I would like to thank the Board of Associates of Hood College...]subtitle: Intellectual Property in the Transition from Natural State to Open Access Orderdate: \todayauthor: - Ryan Safner^[Hood College, Department of Economics and Business Administration; safner@hood.edu]abstract: | | "This paper explores the emergence of the modern forms of copyright and patent in ... | *JEL Classification:* O30, O43, N43 | *Keywords:* Copyright, intellectual property, economic history, freedom of the press, economic developmentbibliography: patronage.bibgeometry: margin = 1infontsize: 12ptmainfont: Fira Sans Condensedoutput: pdf_document: latex_engine: xelatex number_sections: true fig_caption: yesheader-includes: - \usepackage{booktabs}
R
code with three backticks1 above and below your code```{r}2+2 # code goes here!```
2+2 # code goes here!
## [1] 4
1 The key to the left of the #1 key on your keyboard.
2 Yes that does mean you can use other coding languages!
```{r}head(mpg, n=2)```
head(mpg, n=2)
## # A tibble: 2 × 11## manufacturer model displ year cyl trans drv cty hwy fl class ## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr> ## 1 audi a4 1.8 1999 4 auto(l5) f 18 29 p compa…## 2 audi a4 1.8 1999 4 manual(m5) f 21 29 p compa…
```{r}library("ggplot2") # load ggplot2ggplot(data = mpg)+ aes(x = displ)+ geom_histogram()```
library("ggplot2") # load ggplot2ggplot(data = mpg)+ aes(x = displ)+ geom_histogram()
You can add additional options inside the {braces}
after r
, some common options:
Name: you can name your chunk for further reference later (not required)1
r
but before a commaecho
=TRUE
to display the R
code input=FALSE
shows will not show your codeeval
=TRUE
to run your code=FALSE
only displays your code without running itfig
has a lot of options for displaying plot outputs (fig.height
, fig.width
, fig.asp
, etc)
results
will format the output of a chunk in a certain way (used for advanced things we'll talk about later)
```{r my_cool_chunk, echo=F, warning = F}```
```{r check-data, echo = T}# get top 3 avg displacement by manufmpg %>% group_by(manufacturer) %>% summarize(avg = mean(displ)) %>% arrange(desc(avg)) %>% slice(1:3)```
```{r make-plot, echo = F, fig.height=2}ggplot(data = mpg)+ aes(x = displ)+ geom_histogram()```
# get top 3 avg engine displacement by manufmpg %>% group_by(manufacturer) %>% summarize(avg = mean(displ)) %>% arrange(desc(avg)) %>% slice(1:3)
## # A tibble: 3 × 2## manufacturer avg## <chr> <dbl>## 1 lincoln 5.4 ## 2 chevrolet 5.06## 3 jeep 4.58
If you want to be fancy, you can set global options that affect all chunks
Use a special named setup
chunk at top (comes in default .Rmd
template)
knitr::opts_chunk$set()
commandExample on right is what I commonly use in my slides:
```{r setup, include=FALSE}knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, fig.retina = 3)```
If you just want to display some code (or at least format it like code) in the middle of a sentence, place between a single backtick on either side. If I mention tidyverse
or gapminder
, it formats the text as in-line code
.
To actually execute R
code to output something in the middle of a sentence, put r
as the first character inside the backticks, and then run the actual code such as pi is equal to 3.1415927.
pi is equal to `r pi`
.
pi is equal to 3.1415927.
The average GDP per capita is `r gapminder %>% mean(gdpPercap) %>% round(2)`
with a standard deviation of `r round(sd(gapminder$gdpPercap),2)`
.
The average GDP per capita is $7215.33 with a standard deviation of $9857.45.
*italics text*
creates italics text**bold text**
creates bold text Create an unordered list with lines of (- or + or * ), e.g.:
Markdown is great for taking notes quickly!
- item 1- item 2 - item 2a- item 3
Markdown | Output |
---|---|
# Heading 1 |
Heading 1 |
## Heading 2 |
Heading 2 |
### Heading 3 |
Heading 3 |
Comment your code (will not print in output) with <!-- Unprinted comments here -->
(this comes from html)
| Header 1 | Header 2 | |----------|----------|| Cell 1 | Cell 2 || Cell 3 | Cell 4 |
Header 1 | Header 2 |
---|---|
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |
kableExtra
packagehuxtable
package (for regression tables)gt
packageAdd beautifully-formatted math with the $
tag before and after the math, two $$
before/after for a centered equation
In-line math example: $1^2=\frac{\sqrt{16}}{4}$
produces \(1^2=\frac{\sqrt{16}}{4}\)
Centered-equation example:
$$
\hat{\beta_1}=\frac{\displaystyle \sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\displaystyle \sum_{i=1}^n (X_i-\bar{X})^2}
$$
$$\hat{\beta_1}=\frac{\displaystyle \sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\displaystyle \sum_{i=1}^n (X_i-\bar{X})^2}$$
R
and markdown
pdf
or html
output actually converts markdown
files into \(\TeX{}\) first! (See the process described below)Input | Output |
---|---|
$\alpha$ |
\(\alpha\) |
$\pi$ |
\(\pi\) |
$\frac{1}{2}$ |
\(\frac{1}{2}\) |
$\hat{x}$ |
\(\hat{x}\) |
$\bar{y}$ |
\(\bar{y}\) |
$x_{1,2}$ |
\(x_{1,2}\) |
x^{a-1}$ |
\(x^{a-1}\) |
$\lim_{x \to \infty}$ |
\(\lim_{x \to \infty}\) |
$A=\begin{bmatrix} a_{1,1} & a_{1,2} \\ a_{2,1} & a_{2,2} \\ \end{bmatrix}$ |
\(A=\begin{bmatrix} a_{1,1} & a_{1,2} \\ a_{2,1} & a_{2,2} \\ \end{bmatrix}\) |
.bib
files .bib
file to list all of your references inR
via: File -> New File -> Text File
(and save with .bib
at the end)examplebib.bib
in this repository used in this document YAML
header in the main document, add bibliography: examplebib.bib
so R
knows to pull references from this file .bib
file, like so: @article{safner2016, author = {Ryan Safner}, year = {2016}, journal = {Journal of Institutional Economics}, title = {Institutional Entrepreneurship, Wikipedia, and the Opportunity of the Commons}, volume = {12}, number = {4}, pages = {743-771}}
A .bib
file is a plain text file with entries like this
Classes for @article
, @book
, @collectedwork
, @unpublished
, etc.
editor
, publisher
, address
)First input after the @article
is your citation key (e.g. safner2016
)
Whenever you want to cite a work in your text, call up the citation key with @
, like so: @safner2016[]
, which produces (Safner, 2016)
You can customize citations, e.g.:
Write | Produces |
---|---|
[@Safner2016] |
(Safner, 2016) |
@Safner2016 |
Safner 2016 |
-@Safner2016 |
(2016) |
@Safner2016[p. 743-744] |
(Safner, 2016, p.743-744) |
BibTeX will automatically collect all works cited at the end and produce a bibliography according to a style you can choose
We'll see more when we discuss writing your paper
.bib
files to use with R Markdown
Markdown files are plain text files and can be edited in any text editor
Any good editor will have syntax highlighting and coloring when you use tags (like bold, italic, code
, and code #comments
).
Honestly, I write everything in R Studio's text editor
You can write R code in other text editors, but you can't execute them outside of R Studio (or the command line, but that's too advanced.) Same with actually rendering your markdown to an output (pdf, html, etc)
Empty space is very important in markdown
Lines that begin with a space may not render properly
Math that contains spaces between the dollar-signs may not render properly
Moving from one type of content to another (e.g. a heading to a list to text to an equation to text) requires blank lines between them to work
When you are ready, you "compile" your markdown and code into an output format using:
knitr
1, an R package that "knit
s" your R code and markdown .Rmd
into a .md
file for:
pandoc is a "swiss-army knife" utility that can convert between dozens of document types
All you need to do is click the Knit
button at the top of the text editor!
knitr
also relies on the rmarkdown
package, which will probably be installed when you first knit.
R Project
is a way of systematically organizing your R
history, working directory, and related files in a single packageIn almost all cases, you simply want a New Project
For more advanced uses, your project can be an R Package
or a Shiny Web Application
If you have other packages that create templates installed (as I do, in the previous image), they will also show up as options
Enter a name for the project in the top field
Choose the location of the folder on your computer
Depending on if you have other packages or utilities installed (such as git
, see below!), there may be additional options, do not check them unless you know what you are doing
Bottom left checkbox allows you to open a new instance (window) of R
just for this project (and keep existing windows open)
Switch between each project (Window) on your computer (this is on a Mac).
This project is on GitHub, click the green button, download to your computer, open .Rproj
file in R Studio
README
of this repository on GitHub for instructions (automatically shows on the main page)Example_paper.Rmd
.R
scripts from Scripts folderbibexample.bib
from Bibliography folderKeep your files backed up
Track changes
Collaborate on the same files with others
Edit files on one computer and then open and continue working on another?
Register an account for free
Set up a location on your computer for the Dropbox/
folder
Anything you put in this folder will sync to the cloud
My Dropbox - my life goes here
Smart Sync - keep some files online only for space
Git
is an "open source distributed version control system" widely used in the software development industry
Track changes on steroids (if MS Word’s Track Changes and Dropbox had a baby)
"repository"
)commit
") with "comment
s"push
these to the cloudpull
changes to (other) computers as neededGitHub
is a popular (not the only!) cloud destination for these repositories
versions
) of files with commentsfork
or branch
repository into multiple versions at oncerevert
back to original versions as neededRequires some advanced set up, see this excellent guide
R Studio integrates git and github commands nicely
project # folder on my computer (the new working directory)||- Data/ # folder for data files |- Scripts/ # folder .R code|- Bibliography/ # folder for .bib files|- Figures/ # folder to plots and figures to|- paper.Rmd # write document here
paper.Rmd
, loading/saving files from/to various folders in projectdf<-read_csv("Data/my_data")
; save plots like ggsave("Figures/p.png")
pdf
or html
.stage
and commit
changes with a description, push
to GitHub.** Optional and a bit advanced, remember this is my workflow.
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
o | Tile View: Overview of Slides |
Esc | Back to slideshow |
Writing text/documents
Managing citations and bibliographies
Performing data analysis
Making figures and tables
Saving files for future use
Monitoring changes in documents
Collaborating and sharing with others
Combining into a deliverable (report, paper, presentation, etc.)
Writing text/documents
Managing citations and bibliographies
Performing data analysis
Making figures and tables
Saving files for future use
Monitoring changes in documents
Collaborating and sharing with others
Combining into a deliverable (report, paper, presentation, etc.)
A lot of copy-pasting
A lot of...
"'Reproducible research' is a redundant term. 'Irreproducible research' just used to be known as 'bullshit'." - @fperez_org ::slow clap::
— Kaitlin Thaney 💁🏻 (@kaythaney) May 8, 2014
This is how I make my...
I have not used any MS Office products since 2011 (good riddance!)
This stuff is optional
R Markdown
, which can do all of this in one pipelinePlain text files: readable by both machines and humans
Focus entirely on the actual writing of the content instead of the formatting and aesthetics
Open Source: free, useable forever, often very small file size
.doc
file from Microsoft Word 1997?Automate and Minimize Errors, especially in repetitive processes
Can be used with version control (see below)
One day you will need to quit R, go do something else and return to your analysis the next day. One day you will be working on multiple analyses simultaneously that all use R and you want to keep them separate. One day you will need to bring data from the outside world into R and send numerical results and figures from R back out into the world. To handle these real life situations, you need to make two decisions: What about your analysis is "real", i.e. what will you save as your lasting record of what happened? Where does your analysis "live"?
- Hadley Wickham, R For Data Science
We've talked about .R
script files that let you "keep" commands
What about output? Must you save and copy/paste to MS Word? No!
R Markdown
file (.Rmd
) is the "real" part of your analysis, everything can live in this plain-text file!
Document text in markdown
R code
executed in "chunks"
Plots and tables generated from R code
Citations and bibliography automated with .bib
file
File -> New File -> R Markdown...
rticles
or xaringan
add neat templates)File -> New File -> R Markdown...
html
: renders a webpage, viewable in any browserpdf
: renders a PDF documentLaTeX
distribution to render (more on that soon)word
: create a Micosoft Word documentEntire document is written in a single file1 with three types of content:
YAML
header for metadata
Text of the document written with markdown
R
chunks for data analysis, plots, figures, tables, statistics, as necessary
1 The one exception is for managing bibliographies, this requires one additional .bib
file!
Top of a document contains the YAML
1 separated by three dashes ---
above and below
Contains the metadata of the document, such as:
title: "My Title"author: "Ryan Safner"date: "`r Sys.Date()`" # here I'm using R code to generate today's date!output: pdf_document
output
must be specified, everything else can be left blank, and other options can be added as necessary
In most cases, you can safely ignore other things in the yaml
until you are ready
1 YAML stands for "YAML Ain't Markup Language." Nerds love recursive acronyms.
title: Distributing Patronage^[I would like to thank the Board of Associates of Hood College...]subtitle: Intellectual Property in the Transition from Natural State to Open Access Orderdate: \todayauthor: - Ryan Safner^[Hood College, Department of Economics and Business Administration; safner@hood.edu]abstract: | | "This paper explores the emergence of the modern forms of copyright and patent in ... | *JEL Classification:* O30, O43, N43 | *Keywords:* Copyright, intellectual property, economic history, freedom of the press, economic developmentbibliography: patronage.bibgeometry: margin = 1infontsize: 12ptmainfont: Fira Sans Condensedoutput: pdf_document: latex_engine: xelatex number_sections: true fig_caption: yesheader-includes: - \usepackage{booktabs}
R
code with three backticks1 above and below your code```{r}2+2 # code goes here!```
2+2 # code goes here!
## [1] 4
1 The key to the left of the #1 key on your keyboard.
2 Yes that does mean you can use other coding languages!
```{r}head(mpg, n=2)```
head(mpg, n=2)
## # A tibble: 2 × 11## manufacturer model displ year cyl trans drv cty hwy fl class ## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr> ## 1 audi a4 1.8 1999 4 auto(l5) f 18 29 p compa…## 2 audi a4 1.8 1999 4 manual(m5) f 21 29 p compa…
```{r}library("ggplot2") # load ggplot2ggplot(data = mpg)+ aes(x = displ)+ geom_histogram()```
library("ggplot2") # load ggplot2ggplot(data = mpg)+ aes(x = displ)+ geom_histogram()
You can add additional options inside the {braces}
after r
, some common options:
Name: you can name your chunk for further reference later (not required)1
r
but before a commaecho
=TRUE
to display the R
code input=FALSE
shows will not show your codeeval
=TRUE
to run your code=FALSE
only displays your code without running itfig
has a lot of options for displaying plot outputs (fig.height
, fig.width
, fig.asp
, etc)
results
will format the output of a chunk in a certain way (used for advanced things we'll talk about later)
```{r my_cool_chunk, echo=F, warning = F}```
```{r check-data, echo = T}# get top 3 avg displacement by manufmpg %>% group_by(manufacturer) %>% summarize(avg = mean(displ)) %>% arrange(desc(avg)) %>% slice(1:3)```
```{r make-plot, echo = F, fig.height=2}ggplot(data = mpg)+ aes(x = displ)+ geom_histogram()```
# get top 3 avg engine displacement by manufmpg %>% group_by(manufacturer) %>% summarize(avg = mean(displ)) %>% arrange(desc(avg)) %>% slice(1:3)
## # A tibble: 3 × 2## manufacturer avg## <chr> <dbl>## 1 lincoln 5.4 ## 2 chevrolet 5.06## 3 jeep 4.58
If you want to be fancy, you can set global options that affect all chunks
Use a special named setup
chunk at top (comes in default .Rmd
template)
knitr::opts_chunk$set()
commandExample on right is what I commonly use in my slides:
```{r setup, include=FALSE}knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, fig.retina = 3)```
If you just want to display some code (or at least format it like code) in the middle of a sentence, place between a single backtick on either side. If I mention tidyverse
or gapminder
, it formats the text as in-line code
.
To actually execute R
code to output something in the middle of a sentence, put r
as the first character inside the backticks, and then run the actual code such as pi is equal to 3.1415927.
pi is equal to `r pi`
.
pi is equal to 3.1415927.
The average GDP per capita is `r gapminder %>% mean(gdpPercap) %>% round(2)`
with a standard deviation of `r round(sd(gapminder$gdpPercap),2)`
.
The average GDP per capita is $7215.33 with a standard deviation of $9857.45.
*italics text*
creates italics text**bold text**
creates bold text Create an unordered list with lines of (- or + or * ), e.g.:
Markdown is great for taking notes quickly!
- item 1- item 2 - item 2a- item 3
Markdown | Output |
---|---|
# Heading 1 |
Heading 1 |
## Heading 2 |
Heading 2 |
### Heading 3 |
Heading 3 |
Comment your code (will not print in output) with <!-- Unprinted comments here -->
(this comes from html)
| Header 1 | Header 2 | |----------|----------|| Cell 1 | Cell 2 || Cell 3 | Cell 4 |
Header 1 | Header 2 |
---|---|
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |
kableExtra
packagehuxtable
package (for regression tables)gt
packageAdd beautifully-formatted math with the $
tag before and after the math, two $$
before/after for a centered equation
In-line math example: $1^2=\frac{\sqrt{16}}{4}$
produces \(1^2=\frac{\sqrt{16}}{4}\)
Centered-equation example:
$$
\hat{\beta_1}=\frac{\displaystyle \sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\displaystyle \sum_{i=1}^n (X_i-\bar{X})^2}
$$
$$\hat{\beta_1}=\frac{\displaystyle \sum_{i=1}^n (X_i-\bar{X})(Y_i-\bar{Y})}{\displaystyle \sum_{i=1}^n (X_i-\bar{X})^2}$$
R
and markdown
pdf
or html
output actually converts markdown
files into \(\TeX{}\) first! (See the process described below)Input | Output |
---|---|
$\alpha$ |
\(\alpha\) |
$\pi$ |
\(\pi\) |
$\frac{1}{2}$ |
\(\frac{1}{2}\) |
$\hat{x}$ |
\(\hat{x}\) |
$\bar{y}$ |
\(\bar{y}\) |
$x_{1,2}$ |
\(x_{1,2}\) |
x^{a-1}$ |
\(x^{a-1}\) |
$\lim_{x \to \infty}$ |
\(\lim_{x \to \infty}\) |
$A=\begin{bmatrix} a_{1,1} & a_{1,2} \\ a_{2,1} & a_{2,2} \\ \end{bmatrix}$ |
\(A=\begin{bmatrix} a_{1,1} & a_{1,2} \\ a_{2,1} & a_{2,2} \\ \end{bmatrix}\) |
.bib
files .bib
file to list all of your references inR
via: File -> New File -> Text File
(and save with .bib
at the end)examplebib.bib
in this repository used in this document YAML
header in the main document, add bibliography: examplebib.bib
so R
knows to pull references from this file .bib
file, like so: @article{safner2016, author = {Ryan Safner}, year = {2016}, journal = {Journal of Institutional Economics}, title = {Institutional Entrepreneurship, Wikipedia, and the Opportunity of the Commons}, volume = {12}, number = {4}, pages = {743-771}}
A .bib
file is a plain text file with entries like this
Classes for @article
, @book
, @collectedwork
, @unpublished
, etc.
editor
, publisher
, address
)First input after the @article
is your citation key (e.g. safner2016
)
Whenever you want to cite a work in your text, call up the citation key with @
, like so: @safner2016[]
, which produces (Safner, 2016)
You can customize citations, e.g.:
Write | Produces |
---|---|
[@Safner2016] |
(Safner, 2016) |
@Safner2016 |
Safner 2016 |
-@Safner2016 |
(2016) |
@Safner2016[p. 743-744] |
(Safner, 2016, p.743-744) |
BibTeX will automatically collect all works cited at the end and produce a bibliography according to a style you can choose
We'll see more when we discuss writing your paper
.bib
files to use with R Markdown
Markdown files are plain text files and can be edited in any text editor
Any good editor will have syntax highlighting and coloring when you use tags (like bold, italic, code
, and code #comments
).
Honestly, I write everything in R Studio's text editor
You can write R code in other text editors, but you can't execute them outside of R Studio (or the command line, but that's too advanced.) Same with actually rendering your markdown to an output (pdf, html, etc)
Empty space is very important in markdown
Lines that begin with a space may not render properly
Math that contains spaces between the dollar-signs may not render properly
Moving from one type of content to another (e.g. a heading to a list to text to an equation to text) requires blank lines between them to work
When you are ready, you "compile" your markdown and code into an output format using:
knitr
1, an R package that "knit
s" your R code and markdown .Rmd
into a .md
file for:
pandoc is a "swiss-army knife" utility that can convert between dozens of document types
All you need to do is click the Knit
button at the top of the text editor!
knitr
also relies on the rmarkdown
package, which will probably be installed when you first knit.
R Project
is a way of systematically organizing your R
history, working directory, and related files in a single packageIn almost all cases, you simply want a New Project
For more advanced uses, your project can be an R Package
or a Shiny Web Application
If you have other packages that create templates installed (as I do, in the previous image), they will also show up as options
Enter a name for the project in the top field
Choose the location of the folder on your computer
Depending on if you have other packages or utilities installed (such as git
, see below!), there may be additional options, do not check them unless you know what you are doing
Bottom left checkbox allows you to open a new instance (window) of R
just for this project (and keep existing windows open)
Switch between each project (Window) on your computer (this is on a Mac).
This project is on GitHub, click the green button, download to your computer, open .Rproj
file in R Studio
README
of this repository on GitHub for instructions (automatically shows on the main page)Example_paper.Rmd
.R
scripts from Scripts folderbibexample.bib
from Bibliography folderKeep your files backed up
Track changes
Collaborate on the same files with others
Edit files on one computer and then open and continue working on another?
Register an account for free
Set up a location on your computer for the Dropbox/
folder
Anything you put in this folder will sync to the cloud
My Dropbox - my life goes here
Smart Sync - keep some files online only for space
Git
is an "open source distributed version control system" widely used in the software development industry
Track changes on steroids (if MS Word’s Track Changes and Dropbox had a baby)
"repository"
)commit
") with "comment
s"push
these to the cloudpull
changes to (other) computers as neededGitHub
is a popular (not the only!) cloud destination for these repositories
versions
) of files with commentsfork
or branch
repository into multiple versions at oncerevert
back to original versions as neededRequires some advanced set up, see this excellent guide
R Studio integrates git and github commands nicely
project # folder on my computer (the new working directory)||- Data/ # folder for data files |- Scripts/ # folder .R code|- Bibliography/ # folder for .bib files|- Figures/ # folder to plots and figures to|- paper.Rmd # write document here
paper.Rmd
, loading/saving files from/to various folders in projectdf<-read_csv("Data/my_data")
; save plots like ggsave("Figures/p.png")
pdf
or html
.stage
and commit
changes with a description, push
to GitHub.** Optional and a bit advanced, remember this is my workflow.