Search code examples
rlubridate

How can I use English language instead of French with the package 'lubridate'?


So, I have a project on R and I have to create a variable 'month' and 'day', so I decided to use 'lubridate' package. But the displayed days and months are in French, but I want to have it in English.

I hope that somebody can answer me. Thank you in advance.

I have just used these two lines of code, they are good, except the language...

crime19clean$Day <- wday(crime19clean$Newdate, label = TRUE, abbr = TRUE) crime19clean$Month <- month(crime19clean$Newdate, label = TRUE, abbr = TRUE)


Solution

  • use locale:

    lubridate::wday(Sys.Date(), label=T, locale="EN-us")
    #> [1] Sat
    #> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
    lubridate::wday(Sys.Date(), label=T, locale="FR-fr")
    #> [1] sam\\.
    #> Levels: dim\\. < lun\\. < mar\\. < mer\\. < jeu\\. < ven\\. < sam\\.
    

    Created on 2022-11-05 with reprex v2.0.2