library(readr)
dfFires <- read_csv("StudyArea.csv", col_types = list(UNIT = col_character()), col_names = TRUE)
library(dplyr)
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
dfFires_subset<-dfFires %>%
filter(STATE == 'Idaho') %>%
select("YR" = "YEAR_", "CS" = "CAUSE","ACRES" = "TOTALACRES")
knitr::kable(head(dfFires_subset, 5))
| 1987 |
Human |
5 |
| 1991 |
Natural |
150 |
| 1991 |
Human |
800 |
| 1990 |
Natural |
2 |
| 1985 |
Human |
38 |
dfFires_summary<-dfFires_subset %>%
group_by(CS,YR) %>%
summarise(Total_Acres_Quemados=sum(ACRES))
## `summarise()` has grouped output by 'CS'. You can override using the `.groups`
## argument.
knitr::kable(head(dfFires_summary, 5))
| Human |
1980 |
71974.7 |
| Human |
1981 |
219362.4 |
| Human |
1982 |
34016.2 |
| Human |
1983 |
48242.5 |
| Human |
1984 |
36837.8 |
##install.packages("ggplot2")
library(ggplot2)
ggplot(dfFires_summary, aes(x = YR, y = Total_Acres_Quemados, color =CS)) +
geom_line() +
theme_minimal() +
labs(title = 'Total acres quemados por causa y año en Idaho',
x = 'Año',
y = 'Total Acres Quemados') +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
