-
Notifications
You must be signed in to change notification settings - Fork 0
/
6 Scripts.Rmd
46 lines (33 loc) · 1.22 KB
/
6 Scripts.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: "6 Scripts"
author: "Russ Conte"
date: "8/19/2018"
output: html_document
---
# 6. Scripts
## 6.1 Running Code
#from the text: "The key to using the script editor effectively is to memorise one of the most important keyboard shortcuts: Cmd/Ctrl + Enter.
#This executes the current R expression in the console."
#If your cursor is at █, pressing Cmd/Ctrl + Enter will run the complete command that generates not_cancelled.
#It will also move the cursor to the next statement (beginning with not_cancelled %>%).
#That makes it easy to run your complete script by repeatedly pressing Cmd/Ctrl + Enter.
```{r setup, include=FALSE}
library(dplyr)
library(nycflights13)
not_cancelled <- flights %>%
filter(!is.na(dep_delay), !is.na(arr_delay))
not_cancelled %>%
group_by(year, month, day) %>%
summarise(mean = mean(dep_delay))
```
There is a way to run the entire script, not just line-by-line: Cmd/Ctrl + Shift + Enter for the current chunk,
and Option + Command + R to run everything.
```{r setup, include=FALSE}
library(dplyr)
library(nycflights13)
not_cancelled <- flights %>%
filter(!is.na(dep_delay), !is.na(arr_delay))
not_cancelled %>%
group_by(year, month, day) %>%
summarise(mean = mean(dep_delay))
```