library(ggplot2)
library(dslabs)Warning: package 'dslabs' was built under R version 4.5.3
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
library(ggplot2)
library(dslabs)Warning: package 'dslabs' was built under R version 4.5.3
data(package = "dslabs")data("stars", package = "dslabs")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
Create a scatterplot of the magnitude and temperature
ggplot(data = stars, aes(x = temp, y = magnitude, color = type)) +
geom_point(size = 3, alpha = 0.8) +
labs(
title = "Relationship Between Star Temperature and Magnitude",
subtitle = "Stars categorized by their spectral type",
x = "Temperature",
y = "Magnitude",
color = "Star Type",
caption = "Source: DS Labs"
) +
theme_minimal()