title: R: Shifting all dates to one week
body: <p>I think there has been no such question so far, and all the related ones can not solve my problem.</p>
  
  <p>What I have: FB conversation data, with a time stamp for each message</p>
  
  <p>What I want: Plot number of character against time of the week (Monday 14:00 - 356 chars, and so on)</p>
  
  <p>What I found so far: To take advantage of all the fancy plotting functions I should stick to POSIX times. So what I try, is to convert my time to numeric, substract a reference monday, modulo 7, and then convert it back again.</p>
  
  <pre><code>dat$zeitpunkt =  strptime(dat$zeitpunkt, "%Y-%m-%d %H:%M") # Convert date from string to date
  dat$wday = 
      as.POSIXct(
      as.numeric(dat$zeitpunkt - as.POSIXct("01-02-10 00:00",format="%d-%m-%y %H:%M")) %% 7,
      origin = "2010-02-01")
  
  weekdays(dat$zeitpunkt[1]) # returns "Mittwoch"
  weekdays(dat$wday[1])      # returns "Montag"
  </code></pre>
  
  <p>I understand that I could just tweak the reference until I get a wednesday again, but why is happening? Is there a simpler solution?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Edit: Just noticed that the time is also screwed up:</p>
  
  <pre><code>strftime(dat$wday[1])      # "2010-02-03 01:00:02"
  strftime(dat$zeitpunkt[1]) # "2012-11-28 00:50:00"
  </code></pre>
  
  <p>Here I really have no idea what is happening :/</p>
  
  <p>edit2: I want something like this, just with the correct days of the week and times, starting on Monday 00:00 (Or later 5:00, but that is a different story)
  <a href="https://i.stack.imgur.com/iTC25.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iTC25.png" alt="enter image description here"></a></p>