library(tidyverse) library(edr)
winniweather
dataset, printed to the console.winniweather
pivot_longer()
and thus make it more tidy.winni_mod <- winniweather %>% pivot_longer( starts_with("temp"), names_to = "hour", values_to = "temp" ) winni_mod
hour
column with mutate()
.winni_mod <- winni_mod %>% mutate(hour = case_when( hour == "temp00_00" ~ 0L, hour == "temp06_00" ~ 6L, hour == "temp12_00" ~ 12L, hour == "temp18_00" ~ 18L )) winni_mod
yearmonth
column into year
and month
columns.winni_tidy <- winni_mod %>% separate( col = yearmonth, into = c("year", "month"), sep = "-", convert = TRUE ) winni_tidy
arrange()
to put the observations in the correct order.winni_tidy <- winni_tidy %>% arrange(year, month, day, hour) winni_tidy
winni_tidy <- winni_tidy %>% mutate(iso_date = ISOdate(year, month, day, hour)) winni_tidy
winni_tidy
using ggplot.ggplot(data = winni_tidy) + geom_point(aes(x = iso_date, y = temp))
mutate()
and na_if()
functions.winni_tidy <- winni_tidy %>% mutate(temp = na_if(temp, 9999))
winni_tidy %>% select(temp) %>% summary()
winni_tidy
after encoding a missing value.ggplot(data = winni_tidy) + geom_point(aes(x = iso_date, y = temp))
winni_tidy
by the time of day.ggplot(data = winni_tidy) + geom_point(aes(x = iso_date, y = temp)) + facet_wrap(vars(hour), labeller = label_both)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.