-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdplyrAirportsExample.r
93 lines (64 loc) · 2.05 KB
/
dplyrAirportsExample.r
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
library(dplyr)
library(nycflights13)
#############################################
names(airlines)
names(airports)
names(flights)
names(planes)
names(weather)
#############################################
intersect(names(airlines),names(airports) )
# N.B. names of Airlines are not same as names of Airports
intersect(names(flights),names(airports) )
intersect(names(flights),names(airlines) )
################################################
Inspect the airlines data set (simple exercise)
-look up table
##############################################
What is the highest ariport?
What is the most northerly, easterly airport.
\begin{framed}
\begin{verbatim}
> table(airports$dst)
A N U
1329 23 45
xtabs(lat~dst,airports)
group_by(airports,dst)
airportbytype = group_by(airports,dst)
arrange(airportbytype,lat)
airports.other = filter(airports, dst != "A")
airports.other
airports.other = filter(airports, dst != "A")
airports.other = filter(airports, dst %in% c("N","U") )
airports.other = filter(airports, dst == "N" | dst == "U" )
airports.other = filter(airports, dst != "A")
airports.other = filter(airports, dst %in% c("N","U") )
######################################
arrange(airports.other,lat)
arrange(airports.other,desc(lat))
arrange(airports.other,desc(lon))
arrange(airports,desc(lon))
table(airports$tz)
by_tz = group_by(airports,tz)
by_tz = arrange(by_tz, lat)
distinct(by_tz)
by_tz
summarize(by_tz,max(lat))
slice(by_tz,1:3)
#############################################
summarise(weather,month,max(temp))
summarise(weather,max(temp),month)
summarise(weather,max(temp))
weather.mon = group_by(weather,month)
summarise(weather.mon,max(temp))
weather.aug = filter(weather, month==8)
head(weather.aug)
weather.aug$temp
?summarize
summarise(weather.mon,max(temp,na.rm=T))
summarise(weather.mon,count(temp,na.rm=T))
summarise(weather.mon,min(temp,na.rm=T))
dim(weather)
summarise(weather.mon,range(temp,na.rm=T))
summarise(weather.mon,max(temp,na.rm=T)-min(temp,na.rm=T))
summarise(weather.mon,TempRange = max(temp,na.rm=T)-min(temp,na.rm=T))