-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreport.Rmd
104 lines (72 loc) · 2.01 KB
/
report.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
author: tallguyjenks
date: '`r format(Sys.Date())`'
title: Plant_Stuff
output:
html_document:
toc_float: true
theme: darkly
highlight: zenburn
toc: true
toc_depth: 6.0
code_download: true
number_sections: true
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE,
warning = F,
message = F)
```
```{r lib_loading}
# Package names
packages <- c(
"tidyverse",#################################### Tidyverse packages
"here",######################################### Directory management
"DT", "kableExtra",############################# Table libs
"tidylog",###################################### Feedback on Dplyr verbs
"tidytext"
)
# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
install.packages(packages[!installed_packages])
}
# Packages loading
lapply(packages, library, character.only = TRUE) %>%
invisible()
```
```{r data_import}
# Get the Data
# Read in with tidytuesdayR package
# Install from CRAN via: install.packages("tidytuesdayR")
# This loads the readme and all the datasets for the week of interest
# Either ISO-8601 date or year/week works!
tuesdata <- tidytuesdayR::tt_load('2020-08-18')
plants <- tuesdata$plants
threats <- tuesdata$threats
actions <- tuesdata$actions
```
```{r data_viz}
# Plants ----
head(plants)
plants %>%
dplyr::filter(country == "United States") %>%
dplyr::filter(threat_HID == 1)
unique(plants$year_last_seen)
plants %>%
dplyr::filter(year_last_seen == "Before 1900") %>%
dplyr::count(continent, country, sort=T)
plants %>%
dplyr::count(continent, country, sort=T)
plot_me <- plants %>%
dplyr::count(continent, sort=T)
ggplot(plot_me) +
aes(x = continent, weight = n) +
geom_bar(fill = "#0c4c8a") +
theme_minimal()
model_data <- plants %>%
dplyr::select(action_LP,threat_HID)
lm(threat_HID ~ action_LP, data = model_data)
# Threats ----
# Actions ----
```