R Programming/Duration Analysis