dslabs HW

Author

AT

# Load necessary libraries
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.3.3
library(dslabs)
Warning: package 'dslabs' was built under R version 4.3.3
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
# Load the dataset
data("gapminder")
# Create a scatterplot of GDP per capita vs. life expectancy with continent as the color variable
p <- ggplot(gapminder, aes(x = gdp, y = life_expectancy, color = continent)) +
  geom_point(alpha = 0.7) +
  scale_x_log10() +  # Log scale for GDP per capita
  labs(
    title = "Life Expectancy vs. GDP per Capita",
    x = "GDP per Capita (log scale)",
    y = "Life Expectancy",
    color = "Continent"
  ) +
  theme_minimal(base_size = 15) +
  theme(
    plot.title = element_text(hjust = 0.5),
    axis.title.x = element_text(margin = margin(t = 10)),
    axis.title.y = element_text(margin = margin(r = 10))
  )

p
Warning: Removed 2972 rows containing missing values or values outside the scale range
(`geom_point()`).

The dataset used is the gapminder dataset from the dslabs package, which contains data on life expectancy, GDP per capita, and other variables for different countries over time.