I am running a code my colleague has written on his Rstudio some time ago and I am stuck on what appears to be a very silly problem. I have a variable in a dataframe that is a character and represents a date, such as
30jan2016
38feb2016
I need to transform this character string into a date variable and I am using the following:
df$newvar <- format(as.Date(df$oldvar, format="%d%b%Y"), format="%Y%m%d")
This is what I get:
NA
2016-02-28
After some though I realised that my Rstudio is reading the "month" part of the string in Italian (below you can find the comparison of month abbreviations ENG-ITA), and is correctly decoding only what it can read in ITALIAN. Changing global language options didn't help (and anyway R language was already set to English). Any ideas?
Thanks!
ENG    ITA
jan    gen
feb    feb
mar    mar
apr    apr
may    mag
jun    giu
jul    lug
aug    ago
sep    set
oct    ott
nov    nov
dec    dic
NOTE: Of course I could replace parts of the string and then run the piece of code, but I need this code to run on ANY computer, in English.