R 路径上的标准偏差

R 路径上的标准偏差,r,ggplot2,standard-deviation,R,Ggplot2,Standard Deviation,对于下面的数据集,我试图在ggplot上标记SD并突出显示它 ID S1 S2 1 21.09542 71.06014 2 21.09564 71.06064 2 21.09619 71.06128 2 21.09636 71.06242 2 21.09667 71.06564 2 21.09483 71.06619 2 21.09483 71.06619 1 21.09264 71.06633 3 21.08986 71.0

对于下面的数据集,我试图在ggplot上标记SD并突出显示它

ID    S1      S2
1   21.09542  71.06014
2   21.09564  71.06064
2   21.09619  71.06128
2   21.09636  71.06242
2   21.09667  71.06564
2   21.09483  71.06619
2   21.09483  71.06619
1   21.09264  71.06633
3   21.08986  71.06678
3   21.08925  71.06653
3   21.08925  71.06653
1   21.08925  71.06653
and so on...
这是我从数据集的路径 我尝试使用此命令在ggplot上绘制SD:

#Data frame with mean and SD
df4 <- Data %>% group_by(ID) %>% mutate(SD1 = sd(s1)) %>% mutate(SD2 = sd(s2)) %>% mutate(mean_s1 = mean(s1)) %>% mutate(mean_s2 = mean(s2))
我已经通过geom_路径创建了一条路径,现在我想突出显示该路径上的SD。类似这样,高亮显示的路径显示了路径中的SD

plt <- ggplot(df4, aes(x = s1, y = s2, colour = ID), pch = 17) +geom_point()
plt + geom_path(data = rbind(cbind(tail(Data.sel, -1), grp = 1:(nrow(Data.sel)-1)),  
        cbind(head(Data.sel, -1), grp = 2:nrow(Data.sel)-1)),
        aes(group = interaction(grp)), arrow= arrow(type = "closed", angle = 12), colour="grey") +
geom_errorbar(aes(x=Latitude, ymin=Longitude-std.latitude, ymax=Longitude+std.longitude))

请使示例可复制。您是否将您的代码与?@文档进行了比较?我已经制作了SD标记,但在突出显示该路径时仍然存在问题。我的意思是以易于传输的形式提供数据,如使用dput或使用分布和采样函数的丰富工具箱模拟数据,以及使用的绘图代码,这些都会给您带来问题。有关推理和工作提示,请参见线程。