I need to create a variable that measures distance from APP. The center of APP is at the coordinates 1440000 east, 12160000 north. I need to make a new column calculating the euclidean distance between each individual and the center of APP (dist.APP).
This is what I have so far but I'm not sure the equation is correct for two-dimensions:
east = "1440000"
north = "12160000"
b1 = east
b2 = north
dist.APP <- function(a1, b1, a2, b2) {sqrt((a1 - b1)^2 + (a2 -
b2)^2)
apply(datwolfcoy, FUN = dist.APP, MARGIN = 2)
}
Is this how you specify the vectors for the center of APP coordinates?
For adding it as a column for each individual, this didn't quite work and I think it applied to all columns rather than just the individuals since I specified (margin = 2).
I also tried this with no luck:
dist.APP <- data.frame(function(a1, b1, a2, b2) {sqrt((a1 - b1)^2 + (a2 - b2)^2)
}
This is what my data looks like:
ID PackNumber StudyArea CoyoteAncestry(Logit) PrimaryRds SecondaryRds TertiaryRds Deer Moose east north
49-2 1 Out -0.834473518 0.088 0.499 0.015 0.087 0.112 1358690 12086700
49-3 2 Out -2.408854287 0 0.302 0.188 0 0.382 1346840 12099300
49-4 2 Out -3.896934876 0 0.5 0.164 0.057 0.385 1343380 12100000
49-7 2 Out -2.699548556 0 0.5 0.164 0.057 0.385 1343380 12100000