Stars

Author

J Shleifer

How a stars temperature relate’s to its brightness

library(dslabs)
library(tidyverse)
data <- stars
p1 <- data |>
  ggplot(aes(x=magnitude, y=temp, group_by(type), color=factor(type,c("DA","DB","DF","M","K","G","F","A","B","O")))) + # ordering the star types from smallest to largest
  labs(x = "Magnitude/Brightness (Lower Number=Brighter)", y = "Temperature (C°)", title = "How a Star's Temperature Correlates with its Magnitude", color="Spectral Type\n(Small to Large)", caption = "Note that not all star types have a line of best fit. This is \nbecause the types DB, DF, and O only have one entry each.") +
  geom_point() +
  geom_smooth(method=lm, se=FALSE)

p1 + theme_light()
`geom_smooth()` using formula = 'y ~ x'

The dataset I have used is one measuring the brightness, temperature, and spectral type of 96 different stars. Brightness is measured in magnitude which is a logarithmic scale with a difference of five corresponding to a brightness ratio of 100 to 1. I don’t know the difference between DA, DB, and DF but i assumed that they were all neutron stars but based on the type of star they came from as a neutron star has the spectral type D. I created the graph using ggplot2 using geom_point and geom_smooth to find the line of best fit.