Comenzamos con la lectura del Dataframe ‘StudyArea’
dfFires <- read.csv("C:\\Users\\loren\\OneDrive\\Escritorio\\RDataSets\\RDataSets\\StudyArea.csv")
head(dfFires)
## FID ORGANIZATI UNIT SUBUNIT SUBUNIT2
## 1 0 FWS 81682 USCADBR San Diego Bay National Wildlife Refuge
## 2 1 FWS 81682 USCADBR San Diego Bay National Wildlife Refuge
## 3 2 FWS 81682 USCADBR San Diego Bay National Wildlife Refuge
## 4 3 FWS 81682 USCADBR San Diego Bay National Wildlife Refuge
## 5 4 FWS 81682 USCADBR San Diego Bay National Wildlife Refuge
## 6 5 FWS 81682 USCADBR San Diego Bay National Wildlife Refuge
## FIRENAME CAUSE YEAR_ STARTDATED CONTRDATED OUTDATED STATE
## 1 PUMP HOUSE Human 2001 1/1/01 0:00 1/1/01 0:00 California
## 2 I5 Human 2002 5/3/02 0:00 5/3/02 0:00 California
## 3 SOUTHBAY Human 2002 6/1/02 0:00 6/1/02 0:00 California
## 4 MARINA Human 2001 7/12/01 0:00 7/12/01 0:00 California
## 5 HILL Human 1994 9/13/94 0:00 9/13/94 0:00 California
## 6 IRRIGATION Human 1994 4/22/94 0:00 4/22/94 0:00 California
## STATE_FIPS TOTALACRES
## 1 6 0.1
## 2 6 3.0
## 3 6 0.5
## 4 6 0.1
## 5 6 1.0
## 6 6 0.1
Donde Encontramos la siguiente lista de variables:
Donde se hacen presentes tipos desde numericas hasta categoricas, tanto discretas como continuas, en el caso de las numericas.
idaho_fires <- subset(dfFires, STATE == "Idaho")
# Paso 2: Seleccionar y renombrar las columnas
idaho_fires <- idaho_fires[, c("YEAR_", "CAUSE", "TOTALACRES")]
colnames(idaho_fires) <- c("Year", "Cause", "Total_Acres")
idaho_fires$Total_Acres <- as.numeric(idaho_fires$Total_Acres)
# Paso 3: Agrupar por causa y año, y resumir el total de acres quemados
idaho_summary <- idaho_fires %>%
group_by(Cause, Year) %>%
summarise(Total_Acres_Burned = sum(Total_Acres))
## `summarise()` has grouped output by 'Cause'. You can override using the
## `.groups` argument.
idaho_summary$Total_Acres_Burned<- as.numeric(idaho_summary$Total_Acres_Burned)
idaho_summary <- idaho_summary %>%
filter( Cause != " ")
# Imprimir el DataFrame filtrado
print(idaho_summary)
## # A tibble: 79 × 3
## # Groups: Cause [3]
## Cause Year Total_Acres_Burned
## <chr> <int> <dbl>
## 1 Human 1980 71975.
## 2 Human 1981 219362.
## 3 Human 1982 34016.
## 4 Human 1983 48242.
## 5 Human 1984 36838.
## 6 Human 1985 68035.
## 7 Human 1986 43181.
## 8 Human 1987 35128.
## 9 Human 1988 810403.
## 10 Human 1989 28022.
## # ℹ 69 more rows
ggplot(idaho_summary, aes(x = factor(Year), fill = factor(Cause), y = Total_Acres_Burned)) +
geom_dotplot(binaxis = "y", stackdir = "center")
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
Podemos observar que, dependiendo del año, puede haber una gran variabilidad en los valores. Además, se aprecia un aumento en la cantidad total de acres quemados debido a causas naturales, en contraste con las causas humanas, que parecen mantenerse controladas.