我想在facet wrap的标签中创建两种不同大小的文本.
例如:

test <- read.csv(paste0(path, "Costello Artvgl2 for Stack.csv"), sep = ";", dec = ",", header = T)
str(test)
test$Wert <- factor(test$Wert, levels = c("one","two","three","four","five","six"))
test$Sampling.site <- factor(test$Sampling.site, levels = c("Species X Area T","Species Y Area T","Species X Area A","Species Y Area B","Species X Area B","Species Y Area C"))
levels(test$Sampling.site) <- c("Species X\nTotal catch (n=133)", "Species Y\nTotal catch (n=185)", "Species X\nSampling area A (n=57)", "Species Y\nSampling area B (n=122)",
"Species X\nSampling area B (n=76)", "Species …Run Code Online (Sandbox Code Playgroud) 我想计算几个 GPS 点之间的距离。我试过
distm(c(lon1,lat1), c(lon2,lat2), fun = distHaversine)
Run Code Online (Sandbox Code Playgroud)
这仅适用于一点,但不适用于我的数据框中的列。
所以我按照这里的建议尝试:
但是对于这两个计算,我确实得到了不同的结果:
df <- read.table(sep=",", col.names=c("lat1", "lon1", "lat2", "lon2"),text="
7.348687,53.36575,7.348940,53.36507
7.348940, 53.36507,7.350939,53.36484")
# as recommended in the link above
distHaversine(df[,2:1], df[,4:3])
[1] 80.18433 223.97181
# with distm
distm(c(7.348687,53.36575), c(7.348940,53.36507), fun = distHaversine)
[,1]
[1,] 77.54033
distm(c(7.348940, 53.36507), c(7.350939,53.36484), fun = distHaversine)
[,1]
[1,] 135.2317
Run Code Online (Sandbox Code Playgroud)
那么如何计算数据帧列中两个 GPS 点之间的正确距离(即 distm(c(lon1,lat1), c(lon2,lat2), fun = distHaversine))?我仔细检查了这么远的距离,我知道我通过这种方式获得了正确的距离。
提前致谢。