── 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
library(here)
here() starts at C:/Users/Lucas/Documents/Dev/quarto-blog
library(lubridate)
Data
temperature <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-01-07/temperature.csv" )
Rows: 528278 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): city_name, temp_type, site_name
dbl (1): temperature
date (1): date
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Wrangle
city_temp <- temperature %>%filter( city_name %in%c("MELBOURNE", "PERTH", "SYDNEY", "BRISBANE"), date >=as_date("1970-01-01"), date <as_date("2019-01-01") ) %>%group_by(city_name,year =year(date),month =month(date, label =TRUE) ) %>%summarise(temp =mean(temperature, na.rm =TRUE))
`summarise()` has grouped output by 'city_name', 'year'. You can override using
the `.groups` argument.
Plot
ggplot(city_temp, aes(x = year,y = forcats::fct_rev(month),fill = temp )) +geom_raster() +scale_fill_viridis_c(option ="inferno") +theme_minimal() +theme(text =element_text(family ="Fira Sans"),panel.grid =element_blank(),plot.caption =element_text(hjust =0) ) +facet_wrap(~city_name) +labs(title ="Australian Cities Temperature Over Time",subtitle ="Melbourne has lower mean temperatures in comparison",y ="",x ="",fill ="Average \ntemperature \n(°C)",caption ="Data: Australian Bureau of Meteorology\nVis: Lucas C. L. do Carmo" )
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database