library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(hexbin)
library(modelr)
# Load data globally from your local project CSV file
volcano_data <- read_csv("apply it to your data-2(MyData).csv", show_col_types = FALSE)
## New names:
## • `volcano_number` -> `volcano_number...1`
## • `` -> `...13`
## • `` -> `...19`
## • `volcano_number` -> `volcano_number...20`
## • `volcano_number` -> `volcano_number...21`
## • `volcano_number` -> `volcano_number...22`
## • `volcano_number` -> `volcano_number...27`
## • `` -> `...28`
## • `` -> `...29`
## • `` -> `...30`
## • `` -> `...31`
## • `` -> `...32`
## • `` -> `...33`
## • `` -> `...34`
## • `` -> `...35`
# Ensure both column name aliases exist
if ("primary_volcano_type" %in% names(volcano_data) && !"primary_type" %in% names(volcano_data)) {
volcano_data$primary_type <- volcano_data$primary_volcano_type
} else if ("primary_type" %in% names(volcano_data) && !"primary_volcano_type" %in% names(volcano_data)) {
volcano_data$primary_volcano_type <- volcano_data$primary_type
}
volcano_data %>%
ggplot(aes(x = elevation)) +
geom_histogram(binwidth = 250)

volcano_data %>%
filter(!is.na(primary_type)) %>%
ggplot(aes(x = primary_type, y = elevation)) +
geom_boxplot() +
coord_flip()

volcano_data %>%
count(region, tectonic_settings) %>%
ggplot(aes(x = region, y = tectonic_settings, fill = n)) +
geom_tile() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

volcano_data %>%
ggplot(aes(x = latitude, y = elevation)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", linetype = "dashed")
## `geom_smooth()` using formula = 'y ~ x'
