I think you may be looking for something like this. The result is given in hours.
For example: 10:25:00 - 10:35:15 = - 00:10:15 = - (10/60) - (15/3600) = -0.1708333
a = data.frame(Number = c(1, 2, 3), Time = c("10:25:00", "10:35:15", "10:42:26"), stringsAsFactors = FALSE)
x = 2
timeDiff = function(x, a){
as.difftime(a[x, 2]) - as.difftime(a[x+1, 2])
}
result = sapply(2:nrow(a), timeDiff, a)
result
Please note that it's impossible to compute such difference for case Number 3
, ever since a fourth row would be necessary, and the data frame you provided has only 3 rows.
As per Stack Overflow's prompt, I can see you r a new user, Thus, for future nested for-loops, I recommend you explore sapply or lapply, as it will make your code look cleaner and easier to maintain.
If you need any further clarification, don't hesitate to comment my answer. :-)