Module 11 assignment

 

# Step 1: Install packages

install.packages(c(

  "CarletonStats", "devtools", "epanetReader", "fmsb", "ggplot2", 

  "ggthemes", "latticeExtra", "MASS", "PerformanceAnalytics", 

  "psych", "plyr", "prettyR", "plotrix", "proto", 

  "RCurl", "reshape", "reshape2"

))


# Step 2: Load packages

library(ggplot2)

library(ggthemes)

library(latticeExtra)

library(MASS)

library(PerformanceAnalytics)

library(psych)

library(plyr)


install.packages("ggExtra")

library(ggExtra)


# Create a sample dataset

set.seed(123)

df <- data.frame(

  x = rnorm(200, mean = 5, sd = 1.5),

  y = rnorm(200, mean = 5, sd = 1)

)


# Base scatter plot

p <- ggplot(df, aes(x = x, y = y)) +

  geom_point(color = "steelblue", alpha = 0.7) +

  theme_minimal() +

  labs(

    title = "Marginal Histogram Scatter Plot",

    x = "Variable X",

    y = "Variable Y"

  )


# Add marginal histograms

ggMarginal(p, type = "histogram", fill = "lightblue")





For this assignment, I created a marginal histogram scatter plot using ggplot2 and the ggExtra package in R. This visualization combines a scatter plot with histograms along the margins to display both the relationship between two variables and their individual distributions. I chose this plot because it reflects Edward Tufte’s principles of high data density and minimal visual clutter. The design is simple but informative, it allows people to see correlation patterns and data spread togeher. The simple style and efficient use of space make it an effective and good example of Tufte-inspired visualization in R.

Comments

Popular posts from this blog

Final Project LIS4317