The character string is not in the standard explicit format

I have a dataframe (df3) with some values.

One of these values ​​is daedlines.

The data for this value looks something like this:

deadline 1419397140 1418994978 1419984000 1418702400 

These are days, and I want to convert them to this:

 df3$deadline <- as.POSIXct(df3$deadline, origin="1970-01-01") 

As a rule, it worked for me with other data files from other files.

However, he does return this error to me:

 Error in as.POSIXlt.character(as.character(x), ...) : character string is not in a standard unambiguous format 

How can i fix this?

+5
source share
2 answers

Perhaps you have a character or coefficient, and it expects a numeric vector to convert from unix time:

 as.POSIXct(as.numeric(as.character(df3$deadline)),origin="1970-01-01") 
+6
source

As a suggestion for future debugging, you can check your parameter type with

 class(df3$deadline) 

and make sure you pass the correct type as.POSIXlt ().

In the help menu for asPOSIX * ():

Character input is first converted to the "POSIXlt" class by "strptime": numeric input is first converted to "POSIXct". Any conversion that must take place between two time classes requires a time zone: the conversion from β€œPOSIXlt” to β€œPOSIXct” will check the time in the selected time zone.

+2
source

All Articles