Professional Documents
Culture Documents
Madison Roberts
2024-4-7
Import data:
Data <- read_csv("mars-weather.csv")
Source:
https://github.com/the-pudding/data/blob/master/mars-weather/mars-weather.csv
Clean data:
CleanData <- Data %>%
select(month, min_temp, max_temp, pressure) %>%
na.omit()
1
Find average minimum temperature, average maximum temperature, and average pressure:
AvgPerMonth <- CleanData %>%
group_by(month) %>%
summarize(AvgMin = mean(min_temp), AvgMax = mean(max_temp), AvgPressure = mean(pressure)) %>%
ungroup()
AvgPerMonth
## # A tibble: 12 x 4
## month AvgMin AvgMax AvgPressure
## <fct> <dbl> <dbl> <dbl>
## 1 Month 1 -77.2 -15.4 862.
## 2 Month 2 -79.9 -23.4 889.
## 3 Month 3 -83.3 -27.7 877.
## 4 Month 4 -82.7 -25.3 806.
## 5 Month 5 -79.3 -16.7 749.
## 6 Month 6 -75.3 -7.77 745.
## 7 Month 7 -72.3 -0.0141 795.
## 8 Month 8 -68.4 -0.631 874.
## 9 Month 9 -69.2 -2.23 913.
## 10 Month 10 -72.0 -3.33 887.
## 11 Month 11 -72.0 -4.16 857.
## 12 Month 12 -74.5 -7.93 842.
2
Plot a scatter plot of minimum temperature vs. maximum temperature, colored by month:
Plot1 <- ggplot(CleanData, aes(x = min_temp, y = max_temp, color = month)) +
geom_point() +
xlab("Minimum Temperature") +
ylab("Maximum Temperature") +
labs(title = "Minimum Temperature vs. Maximum Temperature on Mars")
Plot1
Minimum Temperature vs. Maximum Temperature on Mars
10
month
Month 1
Month 2
0
Maximum Temperature
Month 3
Month 4
Month 5
−10
Month 6
Month 7
Month 8
−20
Month 9
Month 10
Month 11
−30
Month 12
3
Plot a bar chart of air pressure, colored by month:
Plot2 <- ggplot(CleanData, aes(pressure, fill = month)) +
geom_bar() +
xlab("Pressure") +
ylab("Count") +
labs(title = "Air Pressure on Mars")
Plot2
Air Pressure on Mars
25
month
Month 1
20 Month 2
Month 3
Month 4
15
Month 5
Count
Month 6
Month 7
10
Month 8
Month 9
Month 10
5
Month 11
Month 12