Hey everyone, new to R here and I'm having a bit of trouble. I have a column of data from a csv file, opened on R. It contains different time stamps, for example:
And I'm trying to convert it into time so that when exported into an Excel file it would look like:
So far I've had two problems: I can use the hms function (as.hms) but it only works on numericals. If I convert my data into num, then for example the last time stamp just becomes '8' cause leading zeroes dissappear. The hms function then works but I don't understand why, the times become completely wrong, for example 06:01:02 will become 16:41:42. Otherwise, I've tried strptime to apply on the data as 'characters', but then it just won't work...
Not sure if I've been very clear. Here is my script anyways:
vms <- read_delim("my-pathway",
delim = "/", escape_double = FALSE, col_names = FALSE,
trim_ws = TRUE)
date <- vms[]
heure <- vms[]
latitude <- vms[]
longitude <- vms[]
vitesse <- vms[]
heure <- as.numeric(heure)
df <- data.frame(Date = c(date),
Heure = c(heure),
Latitude = c(latitude),
Longitude = c(longitude),
Vitesse = c(vitesse))
df$Date <- ymd(df$Date)
Sorry its in French. Date is date, heure is hours, and it's on hours that I'm having trouble.
Thanks in advance if anyone can help !!