Assignment 7

Author

Emme Gunther

library(dslabs)
Warning: package 'dslabs' was built under R version 4.5.2
data(stars)
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.5.2
library(tidyverse)
Warning: package 'tibble' was built under R version 4.5.2
Warning: package 'tidyr' was built under R version 4.5.2
Warning: package 'readr' was built under R version 4.5.2
Warning: package 'purrr' was built under R version 4.5.2
Warning: package 'dplyr' was built under R version 4.5.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.0     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ lubridate 1.9.4     ✔ tibble    3.3.1
✔ purrr     1.2.1     ✔ tidyr     1.3.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
ggplot(stars, aes(x = temp, y = magnitude, color = type)) +
  geom_point(size = 3) +
  labs(
    title = "Star Magnitude vs Temperature", 
    caption = "Source: Dslabs",
    x = "Temperature (K)",
    y = "Magnitude"
    ) +
  scale_color_manual(values = c(
    "A" = "red", 
    "B" = "orange",
    "F" = "yellow",
    "G" = "green",
    "K" = "blue",
    "M" = "purple",
    "O" = "pink",
    "DA" = "darkred",
    "DB" = "lightblue",
    "DF" = "lightgreen"
  )) +
  theme_linedraw()

The dataset I used is called “stars”, from the Dslabs package. It contains a variety of stars, classified by the name of the star, its magnitude, temperature in kelvin, and spectral class of the star. I created a scatterplot with the variable “temp” as the x-axis and “magnitude” as the y-axis. Each dot color corresponds to the type of star, as described in the legend. I found it interesting that the star “Alnitak” was the outlier, and the only type “O” star. Most of the other stars share similar temperature and magnitude trends. However, Alnitak is one of a kind, with the highest temperature and one of the lowest magnitudes. If I were to do further research on this topic, I would want to explore why some stars like Alnitak are so unique in their qualities.