I have this data frame individual_dets
which has some lat and long values in it. This is the dataframe
individual_dets = structure(list(location = c("ARB-04", "BIRCHY HEAD", "Boca1",
"BON-AR-S2", "BON-AR-S2", "BON-W-S5"), month = structure(c(12L,
10L, 10L, 8L, 11L, 2L), .Label = c("Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), class = c("ordered",
"factor")), year = c(2018, 2018, 2018, 2018, 2018, 2018), detection_count = c(3L,
256L, 2L, 4L, 2L, 2L), num_unique_tags = c(1L, 1L, 1L, 1L, 1L,
1L), total_res_time_in_seconds = c(0, 1182040, 0, 2732221, 0,
0), latitude = c(24.94808, 44.5713, 26.32559, -49.27732, -49.27732,
-49.27985), longitude = c(-80.45412, -64.03512, -80.07108, 69.48038,
69.48038, 69.47853)), class = c("grouped_df", "tbl_df", "tbl",
"data.frame"), row.names = c(NA, -6L), groups = structure(list(
location = c("ARB-04", "BIRCHY HEAD", "Boca1", "BON-AR-S2",
"BON-AR-S2", "BON-W-S5"), month = structure(c(12L, 10L, 10L,
8L, 11L, 2L), .Label = c("Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), class = c("ordered",
"factor")), .rows = list(1L, 2L, 3L, 4L, 5L, 6L)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE))
However, my dataframe has 4247 observations.
The lat and long values are for coordinates across the ocean in the NW Atlantic. I am trying to calculate the distance from Halifax of these lat and long values.
I have been told to use this function snap points to line
and then use lappy
but I am looking at the structure and I am so lost. Does anyone understand how to code using the function snap points to line
and lappy to get approximate distance?