install.packages(“tidyverse”) library(tidyverse)
airquality <- airquality
str(airquality)
mean(airquality$Temp)
mean(airquality[,4])
median(airquality$Temp)
sd(airquality$Wind)
var(airquality)
airquality\(Month[airquality\)Month == 5] <- “May” airquality\(Month[airquality\)Month == 6] <- “June” airquality\(Month[airquality\)Month == 7] <- “July” airquality\(Month[airquality\)Month == 8] <- “August” airquality\(Month[airquality\)Month == 9] <- “September”
str(airquality)
summary(airquality)
airquality\(Month<-factor(airquality\)Month, levels=c(“May”, “June”,“July”, “August”, “September”))
p1 <- qplot(data = airquality, Temp, fill = Month, geom= “histogram”, bins = 20) p1
p2 <- airquality %>% ggplot(aes(x=Temp, fill=Month)) + geom_histogram(position=“identity”, alpha=0.5, binwidth = 5, color = “white”)+ scale_fill_discrete(name = “Month”, labels = c(“May”, “June”,“July”, “August”, “September”)) p2
p3 <- airquality %>% ggplot(aes(Month, Temp, fill = Month)) + ggtitle(“Temperatures”) + xlab(“Monthly Temperatures”) + ylab(“Frequency”) + geom_boxplot() + scale_fill_discrete(name = “Month”, labels = c(“May”, “June”,“July”, “August”, “September”)) p3
p4 <- airquality %>% ggplot(aes(Month, Temp, fill = Month)) + ggtitle(“Monthly Temperature Variations”) + xlab(“Monthly Temperatures”) + ylab(“Frequency”) + geom_boxplot()+ scale_fill_grey(name = “Month”, labels = c(“May”, “June”,“July”, “August”, “September”)) p4
p5 <- airquality %>% ggplot(aes(Month, Wind, fill = Month)) + ggtitle(“Wind Readings”) + xlab(“Wind Readings”) + ylab(“Frequency”) + geom_boxplot() + scale_fill_discrete(name = “Month”, labels = c(“May”, “June”,“July”, “August”, “September”)) p5
This is my plot of wind readings from the months of May to September using data from the “airquality” dataset. I believe that this plot is the most effective way of demonstrating differences in wind reading between months. You are able to see the maximum, minumum, and median readings (although I do understand that “frequency” may be redundant here). The code I used is very similar to that of plot 3. Embedded in the code is directions to pick up values from “Wind” and provide boxplots. The code also labels the x and y axis appropriately, as well as provides a title for the visualization.