-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab_3.qmd
92 lines (77 loc) · 1.5 KB
/
Lab_3.qmd
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
90
91
92
---
title: "Lab 3"
author: Breyonne Williams
format:
html:
embed-resources: true
editor: visual
---
## Exercise 1
```{r}
download.file(
"https://raw.githubusercontent.com/USCbiostats/data-science-data/master/02_met/met_all.gz",
destfile = "met_all.gz",
method = "libcurl",
timeout = 60
)
met <- data.table::fread("met_all.gz")
```
## Exercise 2
```{r}
dim(met)
head(met)
tail(met)
```
## Exercise 3
```{r}
str(met)
```
## Exercise 4
```{r}
table(met$year)
table(met$day)
table(met$hour)
summary(met$temp)
summary(met$elev)
summary(met$wind.sp)
met[met$elev==9999.0] <- NA
summary(met$elev)
met <- met[temp>-40]
met2 <- met[order(temp)]
head(met2)
```
## Exercise 5
```{r}
met <- met[temp>-15]
met2 <- met[order(temp)]
head(met2)
```
## Exercise 6
```{r}
elev <- met[elev==max(elev), ]
summary(elev)
cor(elev$temp, elev$wind.sp, use="complete")
cor(elev$temp, elev$hour, use="complete")
cor(elev$wind.sp, elev$day, use="complete")
cor(elev$wind.sp, elev$hour, use="complete")
cor(elev$temp, elev$day, use="complete")
```
## Exercise 7
```{r}
hist(met$elev, breaks=100)
hist(met$temp)
hist(met$wind.sp)
library(leaflet)
leaflet(elev) %>%
addProviderTiles('OpenStreetMap') %>%
addCircles(lat=~lat, lng=~lon, opacity=1, fillOpacity=1, radius=100)
library(lubridate)
elev$date <- with(elev, ymd_h(paste(year, month, day, hour, sep= '')))
summary(elev$date)
elev <- elev[order(date)]
head(elev)
elev$date <- c()
elev$temp <- c()
plot(elev$day, elev$temp, type='l')
plot(elev$day, elev$wind.sp, type='l')
```