title: R Find time lapsed in minutes from pairs of "Enter Store" to following "Leave Store" for every Group (Cart.Serial)
body: <p>Here is my first post! Following some requirements I am adding my data:</p>
  
  <pre><code>&gt; dput(head(ctms3))
  structure(list(Date = structure(c(1444136735, 1444136703, 1444136698, 
  1444136670, 1444136645, 1444136644), class = c("POSIXct", "POSIXt"
  ), tzone = "CST"), Cart.Serial = structure(c(114L, 118L, 8L, 
  4L, 35L, 76L), .Label = c("00817AF4", "008191A9", "008191BE", 
  "008191C4", "0081927D", "008192C8", "008192D1", "008192ED", "008193A5", 
  "008193BB", "008193D4", "008193D7", "008193D9", "008193DA", "008193DC", 
  "008193F2", "008193FB", "008193FE", "0081946C", "008194A6", "008194DA", 
  "0081954B", "0081955D", "008195A1", "008195B5", "008195D7", "008195F5", 
  "0081961B", "0081963E", "0081966C", "0081972B", "0081974E", "0081975A", 
  "0081976F", "0081977A", "008197A1", "008197A4", "008197A9", "008197BC", 
  "008197D1", "008197D3", "008197F2", "008197F3", "008197F4", "008197F8", 
  "008197FA", "0081985A", "00836B89", "00836CC4", "0083702B", "0083747E", 
  "008374FF", "0083752C", "0083754A", "008375BB", "008375C7", "008375F9", 
  "0083761D", "0083761F", "0083769B", "0083771D", "0083778A", "0083A4EB", 
  "0083A56B", "0083A570", "0083A5A6", "0083A5C7", "0083A887", "0083B3FE", 
  "0083D5EA", "0083D5FE", "0083D600", "008403C4", "008403DB", "0084049A", 
  "008404A5", "008404A8", "008405EE", "0084077E", "00840CFD", "00840EAD", 
  "00840F0C", "00840F24", "00840F31", "00840F3A", "0084108D", "008410ED", 
  "0084110C", "0084114B", "008413D1", "008413DD", "008413FE", "0084156A", 
  "0084187C", "008446AD", "008446C7", "008447A8", "008447B5", "0084497F", 
  "0084498D", "0084499F", "008449A7", "008449B4", "008449BF", "008449C8", 
  "008449DE", "00844C04", "00844C33", "00844CBF", "00844CEB", "00844D10", 
  "00844D19", "00846BDD", "00846C7C", "00846CDE", "00846CFB", "00846D1A", 
  "00846D20", "00846D24", "00846D2F", "00846D38", "00846D3D", "00846D88", 
  "00846E4F", "00846EA1", "819161", "819187", "819200", "819302", 
  "819313", "819332", "819346", "819353", "819371", "819458", "819606", 
  "819617", "819643", "819731", "819736", "819744", "819764", "819769", 
  "819789", "819798", "819854", "819863", "819875", "819878", "819879", 
  "819889", "819924", "819927", "819954", "8.19E+05", "8.19E+08", 
  "8.20E+09", "8.20E+10", "837059", "837344", "837347", "837387", 
  "837460", "837487", "837513", "837609", "837613", "837624", "837628", 
  "837649", "837652", "837757", "837772", "840242", "840476", "840482", 
  "8.40E+12", "841255", "841257", "841449", "841724", "841775", 
  "841785", "844834", "844835", "844902", "844981", "844994", "8.45E+06", 
  "8.45E+08", "8.45E+11"), class = "factor"), Message = structure(c(3L, 
  3L, 2L, 2L, 3L, 2L), .Label = c("Checkout", "Enter Store", "Leave     Store", 
  "Must Checkout", "Ping", "Post Cashier Must Checkout", "Push Out", 
  "Unlock"), class = "factor")), .Names = c("Date", "Cart.Serial", 
  "Message"), row.names = c(1L, 5L, 6L, 10L, 13L, 14L), class =          "data.frame")
  </code></pre>
  
  <p>Now, I have three columns: "Date", "Cart.Serial" and "Message". I need to group by Cart.Serial and then find the time lapsed between every pair of Enter Store and Leave Store from the Message variable. The result data should then be put in another data frame so I can work with it as sample and extract means and other descriptive statistics.</p>
  
  <p>Thanks.</p>