install.packages(c(“ggplot2”, “plotly”, “leaflet”, “rmarkdown”, “tidyverse”, “gapminder”, “knitr”))
library(ggplot2) library(plotly) library(leaflet) library(tidyverse) library(gapminder) library(knitr)
data(“mtcars”) data(“gapminder”) data(“quakes”)
bar_plot <- mtcars %>% group_by(cyl) %>% summarise(avg_mpg = mean(mpg)) %>% ggplot(aes(x = factor(cyl), y = avg_mpg, fill = factor(cyl))) + geom_col() + labs(title = “Average MPG by Cylinder”, x = “Cylinders”, y = “Average MPG”)
line_plot <- gapminder %>% filter(country == “India”) %>% ggplot(aes(x = year, y = gdpPercap)) + geom_line(color = “steelblue”, size = 1.2) + labs(title = “GDP Per Capita Over Time - India”, x = “Year”, y = “GDP Per Capita”)
scatter_plot <- gapminder %>% ggplot(aes(x = gdpPercap, y = lifeExp, color = continent)) + geom_point(alpha = 0.6) + scale_x_log10() + labs(title = “Life Expectancy vs GDP”, x = “GDP Per Capita (log scale)”, y = “Life Expectancy”)
quake_map <- leaflet(data = quakes[1:100, ]) %>% addTiles() %>% addCircleMarkers(~long, ~lat, radius = ~mag, popup = ~paste(“Magnitude:”, mag))
title: “My Data Visualization Portfolio” author: “Sukumar Elley” output: R_document: theme: cerulean toc: true editor_options: markdown: wrap: 72 —
Welcome to my data visualization portfolio! This site showcases a few projects created in R using ggplot2, plotly, and leaflet.
mtcars %>%
group_by(cyl) %>%
summarise(avg_mpg = mean(mpg)) %>%
ggplot(aes(x = factor(cyl), y = avg_mpg, fill = factor(cyl))) +
geom_col() +
labs(title = "Average MPG by Cylinder", x = "Cylinders", y = "Average MPG")
gapminder %>%
filter(country == "India") %>%
ggplot(aes(x = year, y = gdpPercap)) +
geom_line(color = "steelblue", size = 1.2) +
labs(title = "GDP Per Capita Over Time - India", x = "Year", y = "GDP Per Capita")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
gapminder %>%
ggplot(aes(x = gdpPercap, y = lifeExp, color = continent)) +
geom_point(alpha = 0.6) +
scale_x_log10() +
labs(title = "Life Expectancy vs GDP", x = "GDP Per Capita (log scale)", y = "Life Expectancy")
leaflet(data = quakes[1:100, ]) %>%
addTiles() %>%
addCircleMarkers(~long, ~lat, radius = ~mag, popup = ~paste("Magnitude:", mag))
This is a basic portfolio website showing visualizations using open datasets. All charts were built using R’s ggplot2, leaflet, and plotly.