Trying to calculate the distance matrix between lat/long points in two datasets.... This is my R script code and then the error message. Any ideas on where I am going wrong?
> library(geosphere)
## step 1: open 2000 data for birds and air temp
> birds<-read.table(file.choose(),header=T,sep="\t")
> birds
> temp<-read.table(file.choose(),header=T,sep="\t")
> temp
##step 2: calculate the distance matrix D, which is the distance between lat/long points in your two datasets
> D = distm (birds<- 3:2, temp<- 2:1)
> new_birds =cbind(birds, temp[apply(D , 1 , which.min),])
Error in temp[apply(D, 1, which.min), ] : incorrect number of dimensions