time - How to convert a numeric number in R to timestamp in R? For example, from 62280 to 17:18:00 -


i have rdata file, 1 column in time. however, when load in r, shown in numbers.

for example, 17:18:00 shown 62280 , 06:30:00 shown 23400 , 18:30:00 shown 66600 , 10:30:00 shown 37800 , 01:00:00 shown 3600 .

i figure out number divided 3600 equal time, 23400/3600 = 6.5.

but still stuck how in next step. give clue? also, "divided 3600" standard time conversion in r? if so, there function conversion?

thank you!

1) using chron package gives "times" class object or if prefer character strings use format(times(...)).

library(chron) x <- c(62280, 23400, 66600, 37800, 3600) times(x / (24 * 60 * 60)) ## [1] 17:18:00 06:30:00 18:30:00 10:30:00 01:00:00 

2) using posixct class , no packages can character strings this:

format(as.posixct(x, origin = "1970-01-01", tz = 'utc"), "%h:%m:%s") ## [1] "17:18:00" "06:30:00" "18:30:00" "10:30:00" "01:00:00" 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -