a function I wrote extracts timestamps from a XML document. Timestamps are coupled to events, which are repeated elements of the series element.
series elements have a variable amount of events, so my function returns a data.frame (if the series have the same length). in general it returns a more generic list and I want it to work with matrices as well. I was pointed out (Thanks Eduardo) that 'list' is the generic type, but I still have trouble with functions that work on generic lists but not with more specific types, like data.frame or matrix.
what I need to do with the data at the moment is to see what is the most common distance between timestamps (I expect it to appear (much) more often than 50% of the times), I have written and rewritten a function doing this:
R> mostCommonStep( list(a=cumsum(c(1,3,3,2,3,3,4,3,2,3,3)), b=cumsum(c(2,3,2,3))) )
[1] 3
R> mostCommonStep( data.frame(a=c(2,4,6,8,12,14,18), b=c(12,14,16,18,22,24,28)) )
[1] 2
R> mostCommonStep( matrix(c(2,4,6,8,12,14,18, 12,14,16,18,22,24,28), 7, 2) )
[1] 2
but I would like to see a more "R" conformant version