R Read abbreviated month form a date that is not in English

后端 未结 2 1226
南旧
南旧 2020-12-20 20:45

I have a text file that includes dates, and want to convert it to a datatable.

Converting the dates such as 03-FEB-2011 can be done with

data$fecha &         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-20 21:33

    If you can't add locales to your OS,

    > Sys.setlocale(locale = "es")
    [1] ""
    Warning message:
    In Sys.setlocale(locale = "es") :
    OS reports request to set locale to "es" cannot be honored
    

    the package readr() has ways to specify and even create locales:

    > library(readr) 
    > parse_date("31 DICIEMBRE 2011","%d %B %Y",locale=locale("es"))
    [1] "2011-12-31"
    

提交回复
热议问题