Know the month abbreviations [🇷 for BE/BA]
Hi ElMaestro,

Do you import the data with
❝ Well, some degree of sanity is part of my general goals. But obviously, in that case I should not have gone into bioequivalence to start with.

❝ […] a csv file with dates like "03/Apr/2024" …
❝ The solution I see is to translate every month abbrev in the data to the corresponding month abbrev of my locale and only then can it be sorted. Same thing if I convert the month abbrev to integer. Both options are equally viable. Clumsy, but I will get there. 
Do you import the data with
read.csv()? I would suggest read.table() instead. Then you can makes sure the ugly column is read as characters and it’s easy to split it into day, month, year, and convert to an ISO-date.months <- function(lang = "en") {
if (!lang %in% c("en", "at", "de", "da", "fr"))
stop ("language \"", lang, "\" not implemented.")
switch(lang,
"en" = setNames(1:12, month.abb),
"at" = setNames(1:12, c("Jän", "Feb", "Mär", "Apr", "Mai", "Jun",
"Jul", "Aug", "Sep", "Okt", "Nov", "Dec")),
"de" = setNames(1:12, c("Jan", "Feb", "Mrz", "Apr", "Mai", "Jun",
"Jul", "Aug", "Sep", "Okt", "Nov", "Dec")),
"da" = setNames(1:12, c("jan", "feb", "mar", "apr", "maj", "jun",
"jul", "aug", "sep", "okt", "nov", "dec")),
"fr" = setNames(1:12, c("janv.", "févr.", "mars", "avr.", "mau", "juin",
"juil.", "août", "sept.", "oct.", "nov.", "déc.")))
}
iso.date <- function(lang = "en", datum, sep = "/") {
if (!lang %in% c("en", "at", "de", "da", "fr"))
stop ("language \"", lang, "\" not implemented.")
sep.locs <- gregexec(sep, datum, perl = TRUE)[[1]][1, ]
if (!length(sep.locs) == 2)
stop ("sep \"", sep, "\" must occur exactly twice in each date.")
d <- substr(datum, 1, sep.locs[1] - 1)
m <- substr(datum, sep.locs[1] + 1, sep.locs[2] - 1)
m <- sprintf("%02d", which(names(months(lang)) == m))
y <- substr(datum, sep.locs[2] + 1, nchar(datum))
paste0(y, "-", m, "-", d)
}
# Example with random dates
set.seed(123456)
days <- 7
mons <- 6
day <- sprintf("%02d", round(runif(days, 1, 28), 0))
month <- round(runif(mons, 1, 12))
en.date <- paste0(day, "/", names(months("en")[month]), "/", "2025")
de.date <- paste0(day, "/", names(months("de")[month]), "/", "2025")
da.date <- paste0(day, "/", names(months("da")[month]), "/", "2025")
fr.date <- paste0(day, "/", names(months("fr")[month]), "/", "2025")
dates <- data.frame(lang = rep(c("en", "de", "da", "fr"), each = days),
date = c(en.date, de.date, da.date, fr.date), iso = NA)
for (j in 1:nrow(dates)) {
dates$iso[j] <- iso.date(lang = dates$lang[j], dates$date[j])
}
dates$iso <- as.Date(dates$iso, format = "%F")
str(dates); print(dates[with(dates, order(lang, iso)), ], row.names = FALSE, right = FALSE)
'data.frame': 28 obs. of 3 variables:
$ lang: chr "en" "en" "en" "en" ...
$ date: chr "23/Feb/2025" "21/Dec/2025" "12/Mar/2025" "10/Oct/2025" ...
$ iso : Date, format: "2025-02-23" "2025-12-21" ...
lang date iso
da 15/feb/2025 2025-02-15
da 23/feb/2025 2025-02-23
da 12/mar/2025 2025-03-12
da 11/aug/2025 2025-08-11
da 10/okt/2025 2025-10-10
da 06/nov/2025 2025-11-06
da 21/dec/2025 2025-12-21
de 15/Feb/2025 2025-02-15
de 23/Feb/2025 2025-02-23
de 12/Mrz/2025 2025-03-12
de 11/Aug/2025 2025-08-11
de 10/Okt/2025 2025-10-10
de 06/Nov/2025 2025-11-06
de 21/Dec/2025 2025-12-21
en 15/Feb/2025 2025-02-15
en 23/Feb/2025 2025-02-23
en 12/Mar/2025 2025-03-12
en 11/Aug/2025 2025-08-11
en 10/Oct/2025 2025-10-10
en 06/Nov/2025 2025-11-06
en 21/Dec/2025 2025-12-21
fr 15/févr./2025 2025-02-15
fr 23/févr./2025 2025-02-23
fr 12/mars/2025 2025-03-12
fr 11/août/2025 2025-08-11
fr 10/oct./2025 2025-10-10
fr 06/nov./2025 2025-11-06
fr 21/déc./2025 2025-12-21—
Dif-tor heh smusma 🖖🏼 Довге життя Україна!![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- September trouble ElMaestro 2025-11-10 12:26 [🇷 for BE/BA]
- September trouble mittyri 2025-11-10 20:38
- More months trouble Helmut 2025-11-11 09:37
- More months trouble ElMaestro 2025-11-13 05:20
- Know the month abbreviationsHelmut 2025-11-13 12:45
- Know the month abbreviations ElMaestro 2025-11-14 16:34
- Know the month abbreviationsHelmut 2025-11-13 12:45
- More months trouble ElMaestro 2025-11-13 05:20
- Worse in France Ohlbe 2025-11-12 15:13
- Worse in France ElMaestro 2025-11-14 16:38
