[R] lapply and Two TimeStamps as input

Pete Brecknock Peter.Brecknock at bp.com
Tue Nov 1 01:21:12 CET 2011

alaios wrote:
> Dear all,
> I have a function that recognizes the following format for timestamps
> "%Y-%m-%d %H:%M:%S"
> my function takes two input arguments the TimeStart and TimeEnd
> I would like to help me create the right list with pairs of TimeStart and
> TimeEnd which I can feed to lapply (I am using mclapply actually). 
> For every lapply I want two inputs to be fed to my function. I only know
> how to feed one input to the lapply
> Could you please help me with that?
> I would like to thank you in advance for your help
> B.R
> Alex
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help@ 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.

Is this of any use?

# Data in list - first time is start time, second time is end time
myListStartEnd = list(c(strptime("2010-01-01 09:00:00","%Y-%m-%d %H:%M:%S"),
                        strptime("2011-01-01 11:30:00","%Y-%m-%d
                      c(strptime("2010-12-01 10:00:00","%Y-%m-%d %H:%M:%S"),
                        strptime("2010-12-25 06:00:00","%Y-%m-%d

lapply(myListStartEnd,function(x) x[2]-x[1])

# Output
Time difference of 365.1042 days

Time difference of 23.83333 days



View this message in context: http://r.789695.n4.nabble.com/lapply-and-Two-TimeStamps-as-input-tp3961939p3962139.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list