0

I have a long format dataframe, with two columns:

Original dataframe

At first (I think) I want a wide format dataframe with separate code columns:

wideformat

Then I want that the timestamp variable count up one minute for every unique code+timestamp combination:

related count up wideformat for timestamp

Maybe I just do not know the right technical terms to search this. For any help I will be very grateful.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Melanie
  • 3
  • 2
  • Please provide the code for an example of you problem that we will be able to run. See this [question](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1) for tips on how to do that. It sounds like what you want to do is explained well in this [book](http://r4ds.had.co.nz/). Look at the spread and gather functions and group_by – see24 Jul 19 '18 at 16:10
  • At the Moment I have two datetime variable. One is the 'cometime' of the Treatment. The other is the 'gotime' if the Treatment is over. Both are POSIXlt times. At first I coded the difftime: Fehler$stay <- difftime(Fehler$cometime,Fehler$gotime) Fehler$stay <- abs(Fehler$stay) – Melanie Aug 03 '18 at 06:05
  • Then I rep the rows with the Minute values between: test <- data.frame(Fehler[rep(seq_len(dim(Fehler)[1]),Fehler$stay),1:17, drop= F], row.names=NULL). AND NOW I NEED A NEW VARIABLE WHICH INCREMENT THE MINUTES WITH ALWAYS ONE MINUTE BETWEEN THE UNIQUE COME AND GOTIME. I do not know how to do this. Any idea would be very helpful. – Melanie Aug 03 '18 at 06:20
  • If you edit your question to give a reproducible example with code that I can run on my computer and an example of the output you want I can help. – see24 Aug 07 '18 at 11:50
  • I added a new comment: https://stackoverflow.com/questions/51746845/loop-for-list-element-with-datetime-in-r – Melanie Aug 08 '18 at 12:34
  • Your new question is getting close to what we need but ideally you would also provide some data that could be used the recreate your problem. Otherwise we can't actually run the code you provide. Check out the question that I linked to in my first comment for tips on how to do that. – see24 Aug 08 '18 at 16:31
  • You should delete this question if you asked a new one so that people don't waste time trying to answer it – see24 Aug 09 '18 at 13:23

0 Answers0