[1] 1.07226361 0.28961309 0.51448089 0.02877086 1.16809879 -0.77932607
[7] 0.16475254 0.26947219 -1.15918876 1.02495565
2023-02-01
Only characters with no formatting
Viewable in text editor
Used for plain text storage (.txt
, .csv
) and coding (.R
, .Rmd
, .py
, .m
, .cpp
)
1s and 0s are converted to images, audio, formatted text
WSYIWYG
Binary document files: .docx
, .xlsx
, .pptx
, .pdf
, .png
, .jpg
Console
R scripts (.R
)
R Markdown files (.Rmd
)
Ctrl/Cmd+Enter
Ctrl/Cmd+Alt/Opt+B
Ctrl/Cmd+Alt/Opt+E
Ctrl/Cmd+Shift+S
Open course RStudio project.
Create new R script and save as test.R
.
Type library(palmerpenguins)
.
Is palmerpenguins
loaded? How can you check?
Run the line to load palmerpenguins
.
Type print(penguins)
.
Source the whole script.
Comment out the print(penguins)
line.
Source the script.
An article [. . . ] in a scientific publication is not the scholarship itself, it is merely advertising of the scholarship. The actual scholarship is the complete software development environment and the complete set of instructions which generated the figures — Buckheit & Donoho (1995)
Direct connection between computations and presentation
Updating presentation is a breeze
Transparent and reproducible
Plain text less corruptable
Easily create different kinds of output styles and files
Easily switch between different templates
Markdown uses HTML syntax for comments
<!-- comment here -->
`r `
The answer to 2 + 2 is `r 2 + 2`
The answer to 2 + 2 is 4.
```{r}
rnorm(10, mean = 0, sd = 1)
```
[1] 1.07226361 0.28961309 0.51448089 0.02877086 1.16809879 -0.77932607
[7] 0.16475254 0.26947219 -1.15918876 1.02495565
```{r}
plot(1:10, 2:11)
```
Create new R Markdown file.
Type “The mean of the first 9 digits is `r mean(1:9)`.
”
Knit/render the document.
Create a new code chunk.
Inside the code chunk, load the palmerpenguins
package and print the penguins
data set.
Run the code chunk without knitting the file.
Knit/render the file.
Comments
Comments are not executed by R