I am a beginning programming student, & I am trying to formulate a ridgeline plot of temperature data, using tidyverse to group the temps by month. The initial data looks like this:
I am trying to group the data by month using this code:
class(weather) #what class is dataset = dataframe
head(weather) #structure of the dataset
attach(weather) #attach column names
weather.month <- weather %>%
mutate(month = weather$Day) %>% #sort data by month
group_by(month)
head(weather.month) #view dataset with new month column
class(weather.month$month) #view class of column month = character
By this code, I get the image below:
ggplot(weather.month, aes(x = `High`, y = 'month', fill = stat(x))) +
geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01) +
scale_fill_viridis_c(name = "Temp. [F]", option = "C") +
labs(title = 'Temperatures in Brookings in 2019')
I am trying to get an image like this:
I am assuming I am not grouping the data correctly, but I can't figure out how to fix it....any suggestions?