Hi All, I've a couple of questions i've been struggling with using the time features, can anyone help? sample data
Timestamp user_id 27/05/08 22:57 763830873067 27/05/08 23:00 763830873067 27/05/08 23:01 763830873067 27/05/08 23:01 763830873067 05/06/08 11:34 763830873067 29/05/08 23:08 765253440317 29/05/08 23:06 765253440317 29/05/08 22:52 765253440317 29/05/08 22:52 765253440317 29/05/08 23:04 765253440317 27/06/08 19:34 765253440317 09/07/08 15:45 765329002557 06/07/08 19:24 765329002557 09/07/08 15:46 765329002557 07/07/08 13:05 765329002557 16/05/08 22:40 765329002557 08/06/08 11:24 765329002557 08/06/08 12:33 765329002557 My first question is how can i create a new var creating a filter based on a date? I've tried as.POSIXct.strptime below as well but to no avail.. can anyone give any advice? >Mcookie$timestamp <- as.POSIXct(strptime(Mcookie$timestamp,"%m/%d/%Y %H:%M")) >Mcookie$time <- ifelse(Mcookie$timestamp > strptime("07-08-2008-00:00","%m-%d-%Y-%H:%M",1,0) My second questions refers to finding the time difference in seconds between the first time a user sees something Vs the last.. and engagment time essentially, i see there is the difftime function, is there a more elegant way of working this out then my thoughts (Pysdo code below) sort data by user_id and Timestamp take the head of user_id as new_time_var take the tail of user_id as new_time_var2 use difftime(new_time_var, new_time_var2, units="secs") Mike [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.