I'm starting with the assumption that you already know how to use the calendar, calendar_dates, trips, and stop_times files to determine the trips of interest for your study period. I'm also assuming that you already know how to determine the time interval between scheduled stops. Your problem then reduces to determining the route distance between the stops.
If you are lucky, either the optional shapes.txt or stop_times.txt files contain the optional shape_dist_traveled field. This provides the missing distance parameter.
You may have to convert the distance according to your location. This involves some GIS knowledge. I don't know whether R has this capability.
If the shape_dist_traveled field isn't present, getting the distance isn't difficult if the optional shapes.txt file is present.
You will have to convert the longitude/latitude point coordinates to local coordinates before summing up the individual point-to-point Euclidean distances.
A GIS package helps. I haven't used R, so I don't know how difficult this would be.
If the shapes.txt file isn't present, you are going to have to guess the route from the stop location, that is contained in the stops.txt file.
I'm currently working on a project to do just that. I'm using Open Street Maps as the road network source. I don't know whether I'll be successful.
Hope this helps.