In my table I have a timestamp column in which i want to change the format. I already tried multiple things but it doesnt work. I also can not find examples to change the format in the whole column. First i converted the column to POSIXct then Ive tried to adjsut the format:
#timestamp as POSIXct and lane as numeric
Flows_ALM_2019 %>%
mutate(timestamp = as.POSIXct(timestamp),lane = as.numeric(lane)) -> Flows_ALM_2019
#remove seconds from time in timestamp column
df <- strftime(timestamp, format= "%Y-%m-%d %H:%m")
after trying: df_2019_tsb$timestamp <- format(df_2019_tsb$timestamp,format= "%Y-%m-%d %H:%m")
This is what I had:
and now it changed to:
What am i doing wrong?
You can use format
:
Flows_ALM_2019$timestamp <- format(Flows_ALM_2019$timestamp, "%Y-%m-%d %H:%m")
Or with strftime
.
Flows_ALM_2019$timestamp <- strftime(Flows_ALM_2019$timestamp, "%Y-%m-%d %H:%m")
This is assuming that timestamp
column is of class POSIXct
in your data.