plot()
requires as its argument coordinates of points, each of which must be numeric, while habitat
is character. Think of how you would do this with graph paper to see the problem with that—how many centimeters on the page between forest and bog on the y-axis?
dat <- data.frame(
site =
c("TPB", "TPB", "HBC", "HBC", "CKB", "CKB"),
lat =
c(42.00333, 42.00333, 42.02889, 42.02889, 42.04944, 42.04944),
lng =
c(73, 73, 70, 70, 71, 71),
elev =
c(389, 389, 8, 8, 152, 152),
nspp =
c(6, 5, 16, 6, 18, 14),
habitat =
c("forest", "bog", "forest", "bog", "forest", "bog"))
(log_nspp <- log(dat$nspp))
#> [1] 1.791759 1.609438 2.772589 1.791759 2.890372 2.639057
Looking at the last line of the reprex
just above, what about the associated habitats to you want to display with the nspp
numbers?