R Error in as.POSIXlt.character : string not standard unambiguous format (2 Examples)
In this R tutorial you’ll learn how to deal with the “Error in as.POSIXlt.character : character string is not in a standard unambiguous format”.
Creation of Exemplifying Data
x <- c("1283934195", "1483236115", "1557924294") # Example data x # Print dates in RStudio # [1] "1283934195" "1483236115" "1557924294" |
x <- c("1283934195", "1483236115", "1557924294") # Example data x # Print dates in RStudio # [1] "1283934195" "1483236115" "1557924294"
Example 1: Replicating the Error Message – character string is not in a standard unambiguous format
as.POSIXct(x, # as.POSIXct leads to error origin = "1980-01-01") # Error in as.POSIXlt.character(x, tz, ...) : # character string is not in a standard unambiguous format |
as.POSIXct(x, # as.POSIXct leads to error origin = "1980-01-01") # Error in as.POSIXlt.character(x, tz, ...) : # character string is not in a standard unambiguous format
Example 2: Solving the Error Message – character string is not in a standard unambiguous format
as.POSIXct(as.numeric(as.character(x)), # as.POSIXct returns dates origin = "1980-01-01") # [1] "2020-09-07 10:23:15 CEST" "2027-01-01 03:01:55 CET" "2029-05-14 14:44:54 CEST" |
as.POSIXct(as.numeric(as.character(x)), # as.POSIXct returns dates origin = "1980-01-01") # [1] "2020-09-07 10:23:15 CEST" "2027-01-01 03:01:55 CET" "2029-05-14 14:44:54 CEST"