Im trying to iterate over a dataset to calculate a gcIntermediate distance between the root and the destination columns. I come from programming in python and c# so I understand loops, but not how to do them in R.
Routes <- list()
For (coord in routeCoords)
{
if(!is.na(coord$Root[0])
inter <- gcIntermediate(coord$Root, coord$Destination, n=5)
list.append(routes, inter)
}
The error is
Error: $ operator is invalid for atomic vectors
And it's on the if statement
The dataframe is 2 columns (Root and Destination), each which a tuple with 2 items (lat and lon)
Example Data:
root destination
(2,5) (2,6)
(1,7) (2,8)
I'm going to use the output of this function to plot it onto a ggplot that I already made to represent the routes that people can take from one node to another in physical space.