library("dslabs")
## Warning: package 'dslabs' was built under R version 4.3.1
library(ggplot2)
library(dplyr)
library(readr)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.1
#data(package="dslabs")
STARS BASED ON ITS SPECTRAL CLASSIFICATION: MAGNITUDE, KELVIN
TEMPERTURE, Type
Ever wonder what type of stars are sparkling at night? When light
reaches our eyes its omitting loads of information. Thank fully we have
the spectroscope that help determine what type of star it is. In this
data set the stars are classified by the magnitude of the stars, kelvin
temperture, and classified as 0 through M.
I used the stars data set in dslabs. First I arragned the by its
magnitude, temperture then colored by type. Magnitude of star is how
bright it is. Temperture of the star is how hot the star is.
Classification of the stars is group by the temperture of the stars. The
graph then displaces based y = magnitude, x = temperture then colored by
its spectral classification. The second graph tells you about the names
of the stars. Since it seemed cluttered I made another scatterplot that
focused on the few stars that are around the same temperture (2400K TO
8000K).
Lets Check the data set
head(stars)
## star magnitude temp type
## 1 Sun 4.8 5840 G
## 2 SiriusA 1.4 9620 A
## 3 Canopus -3.1 7400 F
## 4 Arcturus -0.4 4590 K
## 5 AlphaCentauriA 4.3 5840 G
## 6 Vega 0.5 9900 A
Scatterplot with all of the stars with there respective
temperture
p1 <- ggplot(stars, aes(x = temp, y = magnitude, col= type, text = paste("star:", star) ))+
geom_point(alpha= 0.5) +
labs(title= "STARS BASED ON MAGNITUDE KELVIN TEMPERTURE AND SPECTRAL CLASS")+
xlab("Kelvin temperture of the stars") +
ylab("Magnitude or the brightness of the stars")
p1

Scatterplot with names of the stars
p2 <- ggplot(stars, aes(x = temp, y = magnitude, col= type, text = paste("star:", star) ))+
geom_point(alpha= 0.5) +
geom_text(aes(label = star)) +
labs(title= "STARS BASED ON MAGNITUDE KELVIN TEMPERTURE AND SPECTRAL CLASS")+
xlab("Kelvin temperture of the stars") +
ylab("Magnitude or the brightness of the stars")
p2

Filtering by the type of stars
Type_M_K_G_F <- stars %>%
filter(type == "M" | type == "K" | type == "G" | type == "F") %>%
arrange(temp)
Scatterplot From spectral classifcations M, K, G, and F
Type_M_K_G_F %>%
ggplot(aes(x = temp, y = magnitude, col= type, text = paste("star:", star) ))+
geom_point(alpha= 0.5) +
geom_text(aes(label = star))+
labs(title= "STARS THAT ARE CLASSIFED FROM M, K, G, F")+
xlab("Kelvin temperture 2400 to 8000") +
ylab("Magnitude or the brightness of the stars")
