Choose “File → New Project… → New Directory → New Project” from the menu.
Type a name for your new directory, and choose a directory on your local or network drive.
OK.
Close and reopen RStudio. Double-check that the project is still active.
Type and run getwd()
in the console, double-check that the output matches the path to your newly created directory.
%%
, the integer division %/%
, and functions such as floor()
, sin()
, max()
.What happens if you type 5 + <enter> 3 <enter>
? Is the result different from 5 <enter> + 3 <enter>
? Why?
View the mpg
dataset in the viewer pane:
View(mpg)
diamonds
geom_boxplot()
near()
Hint: Make sure you have loaded the tidyverse
package with library(tidyverse)
.
Hint: You can now also use the F1 key.
Choose “File → New file → R script” to create a new script.
Save it, pick a file name. The extension .R
will be added automatically.
Add code to load the tidyverse package on the first line. Save the script.
Copy some expressions and plots you have run before from the interactive tutorial to your script. Save the script.
Use Ctrl + Enter to source a single expression from the script.
Use Ctrl + Shift + Enter to source the entire script.
Restart the R session (via Ctrl + Shift + F10 or via “Session → Restart R”). Source the entire script.
Hint: The keyboard shortcut may not work in your browser.
Choose “File → Knit document” to render the entire output to a single document.
Everything after #
is a comment. Add a regular comment and one prefixed with #'
(hash apostroph). Knit the document. Can you see the difference?
Copyright © 2018 Kirill Müller. Licensed under CC BY-NC 4.0.