r - Conversion from character to date/time returns NA -


i use as.posixct convert characters posixct, na , don't know why. example:

date <- "fri apr 10 11:57:47 2015" date_in_posix <- as.posixct(date, format="%a %b %d %h:%m:%s %y") 

i tried too:

date_in_posix <- as.posixct(date, format="%a %h %d %h:%m:%s %y") 

but result both always:

> date_in_posix [1] na 

maybe input as.posixct long? , when it's long solution?

it's because "fri" , "apr" not correct abbreviations in locale.

use sys.setlocale("lc_time", locale) set r session's locale 1 correctly interpret english abbreviations. see examples section of ?sys.setlocale how specify locale in above function call.

for example, on ubuntu machine be:

> sys.setlocale("lc_time", "en_us.utf-8") > as.posixct("fri apr 10 11:57:47 2015", format="%a %b %d %h:%m:%s %y") [1] "2015-04-10 11:57:47 cdt" 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -