Load the libraries and view the datasets of the DS Labs

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.1      ✔ purrr   1.0.1 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.5.0 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(dslabs)
## Warning: package 'dslabs' was built under R version 4.2.3
data(package="dslabs") 
list.files(system.file("script", package = "dslabs"))
##  [1] "make-admissions.R"                   
##  [2] "make-brca.R"                         
##  [3] "make-brexit_polls.R"                 
##  [4] "make-death_prob.R"                   
##  [5] "make-divorce_margarine.R"            
##  [6] "make-gapminder-rdas.R"               
##  [7] "make-greenhouse_gases.R"             
##  [8] "make-historic_co2.R"                 
##  [9] "make-mnist_27.R"                     
## [10] "make-movielens.R"                    
## [11] "make-murders-rda.R"                  
## [12] "make-na_example-rda.R"               
## [13] "make-nyc_regents_scores.R"           
## [14] "make-olive.R"                        
## [15] "make-outlier_example.R"              
## [16] "make-polls_2008.R"                   
## [17] "make-polls_us_election_2016.R"       
## [18] "make-reported_heights-rda.R"         
## [19] "make-research_funding_rates.R"       
## [20] "make-stars.R"                        
## [21] "make-temp_carbon.R"                  
## [22] "make-tissue-gene-expression.R"       
## [23] "make-trump_tweets.R"                 
## [24] "make-weekly_us_contagious_diseases.R"
## [25] "save-gapminder-example-csv.R"

Load The Dataset

data("stars")

The chunk below is geom point graph dis[laying the comparisons of the stars temperature vs their magnitude

p1 <- stars %>%
  filter(temp <= 3000) %>%
  ggplot(aes(x = magnitude, y = temp, color = type)) +
  geom_point(size = 3, alpha = 0.5, aes(color = type))+
  geom_smooth(method = lm, se = FALSE, color = "black", lty=2, size = 0.3)+
  scale_size_area()+
    xlab("Magnitude of Stars") +
  ylab("Temp (in Kelvin) of Stars") +
  ggtitle("Selected Stars 3000k+")+
theme_minimal(base_size = 14, base_family = "serif") 
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
p1
## `geom_smooth()` using formula = 'y ~ x'

The plot belwo shows us the previous geom point graph but in ggplotly, more interactive and detailed per point.

ggplotly(p1) 
## `geom_smooth()` using formula = 'y ~ x'

The chunk below will show us a heatmap of the Stars temperature and magnitude of our dataset. The higher magnitude of a star is how bright it will be.

stars <- stars[!duplicated(stars),]
rownames(stars) <- stars$star
stars = stars[,!(names(stars) %in% c("star", "type"))]

stars_matrix <- as.matrix(stars)
stars_heatmap <-heatmap(stars_matrix, Colv = NA, Rowv = NA,scale="column", xlab = "Star Temp and Magnitude", ylab = "Stars", main = "Who's Hotter? Who's Brighter of the Stars?")

The chunk below was to run the dataset again in order for the p1 plot to run. For some reason after the heatmap is created the plots will not run.

data("stars")

The dataset I’ve used from the DS Labs package was the “Stars” dataset. I thought it was pretty interesting to see the magnitude, how bright, and temperature of stars. I used a geom point ggplot and heatmap to compare the variables of temperature and magnitude. If a star has a high temperature is it hotter? Is the sun the brightest star because it provides us with heat? This assignment was very infomative through the visualizations and I hope I depicted that through the chunks.