1

I have the following dataframe (firstweek). The number of rows is very high: 165992. I have 14 different users. I would like to create automatically 14 different dataframes, one for each user. I addition I would like to add in each dataframe a column with the time differences. I am not an expert with R.

> head(firstweek)
                 times        users signal log
14 2014-01-13 00:00:16 00250902DC7A   true  ON
28 2014-01-13 00:00:47 00250902DC7B   true  ON
42 2014-01-13 00:01:18 00250902DC7C   true  ON
56 2014-01-13 00:01:48 00250902DC7E   true  ON
70 2014-01-13 00:02:19 00250902DC7F   true  ON
84 2014-01-13 00:02:50 00250902DC7G   true  ON

> nrow(firstweek)
[1] 165992
Thomas
  • 43,637
  • 12
  • 109
  • 140
antonio
  • 77
  • 10
  • 2
    Welcome to StackOverflow. A few things: (1) You are asking two questions, ask them separately since they're unrelated. (2) Please read about how to supply data in a [reproducible format](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). (3) The answer to your first question is to use `split(firstweek, firstweek$users)`. (4) Search SO for an answer to your second question, as there are many similar questions. – Thomas Feb 20 '14 at 15:53
  • Why do you want to split this data.frame? It seems more useful to keep it as one object and use functions from plyr or dplyr or ... to do operations by `users`. – Roland Feb 20 '14 at 15:54
  • hi Roland i thought it was easier for my brain... so there is a way to compute time differences between two consecutive rows by each user...Many thanks Thomas & Roland – antonio Feb 20 '14 at 16:11

0 Answers0