Hello,

Try the following.


mat <- data.matrix(read.table(text="
2011    7   21   15   25 20.609
2011    7   21   15   25 23.265
2011    7   21   15   25 26.000
2011    7   21   15   25 28.671
2011    7   21   15   25 31.343"))

secs <- apply(mat, 1, function(x)
     ISOdatetime(x[1], x[2], x[3], x[4], x[5], x[6]))
diff(secs)

# convert to date/time if you need them
dates <- as.POSIXlt(secs, origin="1970-01-01")
diff(dates)

Hope this helps,

Rui Barradas
Em 31-07-2012 13:58, Alaios escreveu:
> Dear all,
> I am having a matrix that stores data information in the following format.
>
>> roofPart1$TimeStamps[1:5,]
>       [,1] [,2] [,3] [,4] [,5]   [,6]
> [1,] 2011    7   21   15   25 20.609
> [2,] 2011    7   21   15   25 23.265
> [3,] 2011    7   21   15   25 26.000
> [4,] 2011    7   21   15   25 28.671
> [5,] 2011    7   21   15   25 31.343
>
>
> I would like to be able to report some simple statistics based on the time differences of two entries. For example to check the time consistency (was my device measuring at same intervals ?)
>
> I think the easiest would be to convert the matrix above to pure seconds and then just substract them
>
>
> so something like that ...
>
> makeSeconds(roofPart1$TimeStamps[1:5,2])-makeSeconds(roofPart1$TimeStamps[1:5,1])
> makeSeconds(roofPart1$TimeStamps[1:5,3])-makeSeconds(roofPart1$TimeStamps[1:5,2])
> makeSeconds(roofPart1$TimeStamps[1:5,4])-makeSeconds(roofPart1$TimeStamps[1:5,3])
>
>
> Do you know which are the functions for that? A) convert time stamps to seconds, B) substract the concecutive elements of the seconds matrix
>
>
> I would like to thank you in advance for your help
>
> B.R
> Alex
> 	[[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.


	[[alternative HTML version deleted]]

