-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrTutorial.R
More file actions
57 lines (34 loc) · 1009 Bytes
/
rTutorial.R
File metadata and controls
57 lines (34 loc) · 1009 Bytes
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
47
48
49
50
51
52
53
54
55
# install.packages('devtools')
# if (packageVersion("devtools") < 1.6) {
# install.packages("devtools")
# }
# devtools::install_github("hadley/lazyeval")
# devtools::install_github("hadley/dplyr")
# The r environment
# - how can r be used
# - custom interface
# libraries
library(readr)
library(dplyr)
library(ggplot2)
# Object types
# - numeric
# - character
# - logical
# Data structures and cohersion
# - vector and matrix
# - data.frame
# Importing and inspecting csv
# Selections in a data frame df[row, column]
# - by number
# - by name
# Dropping columns
# Manipulating the data with dplyr!
# - complex selections - ??select()
# - Piping!
# - arrange fars3 by fatalities in descending order
# - add a colum DATE to fars3 that is the full date year/month/day
# - summarize fars 4 by total fatalities and total drunk incidents, and its ratio
# Some simple graphics - fatalities in time
# - first we create a dataset and make a date object
# - let's group by date of the accident