Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Transformation of a vector to a data frame with two columns in R

$
0
0

I have the following dataset, it consists of ID's (integer, although all is stored as a factor) and units of time, which belong to the ID above (see an excerpt of data below, total data has 300'000+ values).

10000007
01:33:28
00:00:05
10000010
00:00:39
00:02:21
00:05:59
00:40:40
00:09:53
10000014
00:09:37
00:00:00
00:00:15
00:00:02
00:40:51
10000022
00:41:44
01:32:32
10000023
01:07:14
01:25:27
1000003
00:00:58
00:03:42
00:05:58
00:00:29
00:00:01
00:04:02
00:00:10
00:01:08
00:07:52
00:10:18
00:12:52
00:09:39
00:07:48
00:04:29

What I want is a data frame, which has in one column the ID and the other column the time. Something like this:

10000007  01:33:28
10000007  00:00:05
10000010  00:00:39
10000010  00:02:21
10000010  00:05:59
10000010  00:40:40
10000010  00:09:53
10000014  00:09:37
10000014  00:00:00
10000014  00:00:15
10000014  00:00:02
10000014  00:40:51
...

I struggle with the fact that the number of time stamps differs between the different ID's and the fact that I can't change the format to numeric efficiently, which might make the operation handier.

Eventually, the idea is to have the times summed up to have only one time per ID. Thank you very much in advance!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>