0
votes

Below are two columns with what I have and what I want. I need to convert the have into want. Essentially, I am creating a 24 hour time sequence.

HAVE 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

WANT 0:00 0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13 0:14 0:15 0:16 0:17 0:18 0:19 0:20 0:21 0:22 0:23 0:24 0:25 0:26 0:27 0:28 0:29 0:30 0:31 0:32 0:33 0:34 0:35 0:36 0:37 0:38 0:39 0:40 0:41 0:42 0:43 0:44 0:45 0:46 0:47 0:48 0:49 0:50 0:51 0:52 0:53 0:54 0:55 0:56 0:57 0:58 0:59 1:00 1:01 1:02 1:03 1:04 1:05 1:06 1:07 1:08 1:09 1:10 1:11 1:12 1:13 1:14 1:15 1:16 1:17 1:18 1:19 1:20 1:21 1:22 1:23 1:24 1:25 1:26 1:27 1:28 1:29 1:30 1:31 1:32 1:33 1:34 1:35 1:36 1:37 1:38 1:39 1:40 1:41 1:42 1:43 1:44 1:45 1:46 1:47 1:48 1:49 1:50 1:51 1:52 1:53 1:54 1:55 1:56 1:57 1:58 1:59

1
What are the rules for conversion?pogibas

1 Answers

1
votes

You can do this with the package chron:

install.packages("chron")

I reproduced a short version of your data as follows:

list1 <- c(0,1,2,3, 68)

The code that you should use is the following - replacing the list1 with the name of your list or dataframe column.

library(chron)
substr(times((list1%/%60 +  list1%%60 /60)/24), 1, 5)