── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── 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
# data("stars")
#check for NA valuesanyNA(stars)
[1] FALSE
#graphstarsdf <- starsstarsdf |>filter(!c(type =="DA"| type =="DB"| type =="DF")) |>#filtering out dwarf planets which arent included in the standard OBAFGKM systemmutate(type =fct_relevel(type, "O", "B", "A", "F", "G", "K", "M")) |>#ordering in order of the OBAFGKM systemggplot(aes(x = temp, y = magnitude, color = type, size = temp)) +labs(x ="Surface Temperature in Kelvin",y ="Magnitude",title ="Properties of Stars - Magnitude vs. Temperature") +theme_light() +geom_point(alpha =0.6)
For my visualization, I used the “stars” dataset from DS Labs, which contains data on the physical properties of 96 stars. It only contains four variables: the name of the star, the magnitude, class of star, and temperature. My visualization displays all 96 stars graphed according to its surface temperature and magnitude.
The primary variable I wanted to incorporate was the class of star which is determined by color. The star type is said to be determined by the OBAFGKM system, yet the first thing I noticed when I was graphing is some stars had other letters under “type” like DA, DB, and DF. These turned out to be dwarf stars. Since they don’t seem to have a place in the spectral class system being used, I decided to omit them altogether.
Next, I wanted to make sure the class of the stars were sorted in the correct order, as they were defaulted to alphabetical. Finally, my graph was able to show that in the OBAFGKM class, stars seem to be sorted according to their temperature. Dots of the same colors lie in similar temperature ranges, while the magnitude differs. However, stars with a higher magnitude (over 5) tend to have a lower surface temperature. Overall, it’s interesting to see the relationships between the physical properties of stars. One thing I’d love to do if I had more time is make the graph interactive so that mousing over the points gives you the title of each star.