library(tidyverse)
library(ggplot2)
library(dplyr)
library(dslabs)
library(ggthemes)
data("stars")Assignment 7 Data 110
Load Libraries and Data
Plot
ggplot(data = stars, aes(x=temp, y=magnitude, color=type)) +
geom_point() +
geom_smooth(method="lm", se = FALSE, color = "aquamarine") +
labs(x = "Star Temperature", y = "Star Magnitude", title = "Star Magnitude vs Temperature by Star Type", caption = "DSLabs") +
scale_color_manual(values = c("red", "orange", "yellow", "green", "blue", "purple", "violet", "brown4", "black", "pink")) +
theme_economist()`geom_smooth()` using formula = 'y ~ x'
cor(stars$magnitude, stars$temp)[1] -0.6331908
Paragraph
The dataset from DSLabs I used was the dataset stars. The dataset includes information about 96 stars, this data includes the stars name, the magnitude of the star, the temperature of the star, and the type of star the star is. In my plot I wanted to see if there was any sort of connection/correlation between the star’s temperature and their magnitude. I made the x axis the stars temperature and the y axis its magnitude to see if the stars temperature had any impact on the magnitude of the star. I then colored each star by their type to see where type of star stood in terms of their temperature and magnitude. The plot shows that there is a moderate negative correlation between star temperature and magnitude and the correlation taken above supports this as the correlation coeffecient is -0.6332 showing that there is a modern negative correlation between the two variables.