I have a dataset which looks like that
I want to change the col_type of the Date from character to date. But when I try I get an error.
northtemp <- read_table(file = "stasjonsdata-3.txt",
col_names = c("Location", "Date", "Hour", "Depth", "Temperature"),
col_types = cols(Date = col_date("%m.%Y")),
skip = 1)
I have done the same thing with data that is in .csv format. This is what I am trying to replicate
florida <- read_delim(file = "Florida-precip.csv",
delim = ";",
locale = locale(decimal_mark = ","),
col_names = c("name", "station", "date", "precip"),
skip = 1,
col_types = cols(date = col_date("%m.%Y")))
florida <- florida |>
mutate(
month = month(date, label = TRUE),
year = year(date))
florida
florida |>
group_by(month) |>
summarise(precip = mean(precip)) |>
ggplot(aes(x = month, y = precip, fill = precip)) +
geom_col() +
labs(x = "", y = "Precipitation mm")