-
Notifications
You must be signed in to change notification settings - Fork 32
/
05_wind_turbines.Rmd
89 lines (67 loc) · 2.46 KB
/
05_wind_turbines.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
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
name: windturbinelocations01
# Wind Turbine Locations
This data on wind turbine locations comes via the #TidyTuesday project. I map the positions of the turbines in the US.
```{r, echo = F}
dir <- "raw_data"
file <- paste0(dir, "/", "us_wind.csv")
url <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2018/2018-11-06/us_wind.csv"
# create raw_data folder
if (!dir.exists(dir)) { dir.create(dir) }
# download data from internet and save
if (!file.exists(file)) { download.file(url = url, destfile = file) }
# read in downloaded data
us_wind <- readr::read_csv(file)
```
A random sample from the data set:
```{r, echo = F}
knitr::kable(head(us_wind, 5), format = "html")
```
```{r, echo = F}
usa <- map_data("state")
```
---
```{r wind_01, eval=F, echo=F}
ggplot(data = usa) +
aes(x = long, y = lat, group = group) +
geom_polygon(fill = "blue", alpha = .4) +
theme_classic() +
coord_map(projection = "mercator") +
geom_point(data = us_wind %>% filter(ylat < 50 & ylat > 25),
mapping = aes(x = xlong, y = ylat, group = NULL),
size = .5, col = "orange", alpha = .6) +
theme_void() +
labs(title = "Wind turbines in the continental US") +
labs(caption = "Tidy Tuesday exercise") +
labs(subtitle = "Data Source: | Visualization: Gina Reynolds")
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "wind_01"
eval(parse(text = paste(knitr:::knit_code$get(get_what_save_what), collapse = "")))
ggsave(paste0("figures/", get_what_save_what, ".png"), dpi = 300)
```
`r apply_reveal("wind_01")`
---
name: windturbinelocations02
```{r, echo=F}
data <- us_wind %>%
filter(ylat < 50 & ylat > 25)
```
```{r wind_02, eval=F, echo=F}
ggplot(data) +
aes(x = xlong, y = ylat) +
borders("state") +
geom_point(col = "steelblue", alpha = .2) +
theme_void() +
coord_map(projection = "mercator") +
geom_density_2d(col = "darkgrey") +
labs(title = "Wind turbines in the continental US") +
labs(caption = "Tidy Tuesday exercise") +
labs(subtitle = "Data Source: | Visualization: Gina Reynolds")
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "wind_02"
eval(parse(text = paste(knitr:::knit_code$get(get_what_save_what), collapse = "")))
ggsave(paste0("figures/", get_what_save_what, ".png"), dpi = 300)
```
`r apply_reveal("wind_02")`
---