1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
library(stringr)
library(scales)
# jour, mois, année
date_fr <- c("06-01-2021", "06-14-2021", "07-07-2021", "08-24-2021",
"09-07-2021", "10-08-2021")
p <- "(\\d{2})-(\\d{2})-(\\d{4})"
# année, jour, mois
date_en <- str_replace(date_fr, p, "\\3-\\1-\\2")
df <- data.frame("Date" = as.Date(date_en),
"id" = "ID1",
"Value ()" = 1:6,
"Quantité" = 1:6,
stringsAsFactors = F)
names(df) <- c("Date", "id", "v.euro", "q")
ggplot(df, aes(x = Date, y = v.euro)) +
geom_point() +
theme_bw() +
labs(x = "Date", y = "Value ()") + # je nomme l'axe y comme je le souhaitais
scale_x_date(labels = date_format("%d-%m-%Y")) # je remets la date en français |
Partager