I decided to use the stars dataset. I filtered the dataset to focus only on M-type stars because they are the most common. Then, I created a scatterplot to illustrate the impact of temperature on the magnitude of these stars.
library(tidyverse)
── 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.0 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── 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
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
7 Capella -0.6 5150 G
8 Rigel -7.2 12140 B
9 ProcyonA 2.6 6580 F
10 Betelgeuse -5.7 3200 M
11 Achemar -2.4 20500 B
12 Hadar -5.3 25500 B
13 Altair 2.2 8060 A
14 Aldebaran -0.8 4130 K
15 Spica -3.4 25500 B
16 Antares -5.2 3340 M
17 Fomalhaut 2.0 9060 A
18 Pollux 1.0 4900 K
19 Deneb -7.2 9340 A
20 BetaCrucis -4.7 28000 B
21 Regulus -0.8 13260 B
22 Acrux -4.0 28000 B
23 Adhara -5.2 23000 B
24 Shaula -3.4 25500 B
25 Bellatrix -4.3 23000 B
26 Castor 1.2 9620 A
27 Gacrux -0.5 3750 M
28 BetaCentauri -5.1 25500 B
29 AlphaCentauriB 5.8 4730 K
30 AlNa'ir -1.1 15550 B
31 Miaplacidus -0.6 9300 A
32 Elnath -1.6 12400 B
33 Alnilam -6.2 26950 B
34 Mirfak -4.6 7700 F
35 Alnitak -5.9 33600 O
36 Dubhe 0.2 4900 K
37 Alioth 0.4 9900 A
38 Peacock -2.3 20500 B
39 KausAustralis -0.3 11000 B
40 ThetaScorpii -5.6 7400 F
41 Atria -0.1 4590 K
42 Alkaid -1.7 20500 B
43 AlphaCrucisB -3.3 20500 B
44 Avior -2.1 4900 K
45 DeltaCanisMajoris -8.0 6100 F
46 Alhena 0.0 9900 A
47 Menkalinan 0.6 9340 A
48 Polaris -4.6 6100 F
49 Mirzam -4.8 25500 B
50 DeltaVulpeculae 0.6 9900 A
51 *ProximaCentauri 15.5 2670 M
52 *AlphaCentauriB 5.8 4900 K
53 Barnard'sStar 13.2 2800 M
54 Wolf359 16.7 2670 M
55 HD93735 10.5 3200 M
56 *L726-8 15.5 2670 M
57 *UVCeti 16.0 2670 M
58 *SiriusA 1.4 9620 A
59 *SiriusB 11.2 14800 DA
60 Ross154 13.1 2800 M
61 Ross248 14.8 2670 M
62 EpsilonEridani 6.1 4590 K
63 Ross128 13.5 2800 M
64 L789-6 14.5 2670 M
65 *GXAndromedae 10.4 3340 M
66 *GQAndromedae 13.4 2670 M
67 EpsilonIndi 7.0 4130 K
68 *61CygniA 7.6 4130 K
69 *61CygniB 8.4 3870 K
70 *Struve2398A 11.2 3070 M
71 *Struve2398B 11.9 2940 M
72 TauCeti 5.7 5150 G
73 *ProcyonA 2.6 6600 F
74 *ProcyonB 13.0 9700 DF
75 Lacaille9352 9.6 3340 M
76 G51-I5 17.0 2500 M
77 YZCeti 14.1 2670 M
78 BD+051668 11.9 2800 M
79 Lacaille8760 8.7 3340 K
80 KapteynsStar 10.9 3480 M
81 *Kruger60A 11.9 2940 M
82 *Kruger60B 13.3 2670 M
83 BD-124523 12.1 2940 M
84 Ross614A 13.1 2800 M
85 Wolf424A 15.0 2670 M
86 vanMaanen'sStar 14.2 13000 DB
87 TZArietis 14.0 2800 M
88 HD225213 10.3 3200 M
89 Altair 2.2 8060 A
90 ADLeonis 11.0 2940 M
91 *40EridaniA 6.0 4900 K
92 *40EridaniB 11.1 10000 DA
93 *40EridaniC 12.8 2940 M
94 *70OphiuchiA 5.8 4950 K
95 *70OphiuchiB 7.5 3870 K
96 EVLacertae 11.7 2800 M
Filtering to only M type stars
stars2 <- stars %>%filter(type =="M")stars2
star magnitude temp type
1 Betelgeuse -5.7 3200 M
2 Antares -5.2 3340 M
3 Gacrux -0.5 3750 M
4 *ProximaCentauri 15.5 2670 M
5 Barnard'sStar 13.2 2800 M
6 Wolf359 16.7 2670 M
7 HD93735 10.5 3200 M
8 *L726-8 15.5 2670 M
9 *UVCeti 16.0 2670 M
10 Ross154 13.1 2800 M
11 Ross248 14.8 2670 M
12 Ross128 13.5 2800 M
13 L789-6 14.5 2670 M
14 *GXAndromedae 10.4 3340 M
15 *GQAndromedae 13.4 2670 M
16 *Struve2398A 11.2 3070 M
17 *Struve2398B 11.9 2940 M
18 Lacaille9352 9.6 3340 M
19 G51-I5 17.0 2500 M
20 YZCeti 14.1 2670 M
21 BD+051668 11.9 2800 M
22 KapteynsStar 10.9 3480 M
23 *Kruger60A 11.9 2940 M
24 *Kruger60B 13.3 2670 M
25 BD-124523 12.1 2940 M
26 Ross614A 13.1 2800 M
27 Wolf424A 15.0 2670 M
28 TZArietis 14.0 2800 M
29 HD225213 10.3 3200 M
30 ADLeonis 11.0 2940 M
31 *40EridaniC 12.8 2940 M
32 EVLacertae 11.7 2800 M
Creating Graph
ggplot(stars2, aes(x = magnitude, y = temp)) +labs(title ="The Impact Temperature has on higher Magnitude M Stars") +xlab("Magnitude") +ylab("Temperature") +geom_point (color ="pink") +geom_smooth(color ="yellow") +theme_dark(base_size =12)
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'