R extract line endpoints

Extracting line end nodes in R

I noticed the maptools package in R had a SpatialLinesMidPoints function but couldn’t find any other out of the box functions in any packages to extract line endpoints. So I modified SpatialLinesMidPoints slightly to do the job: