我在向图表添加一些趋势线时遇到了困难。
p<-ggplot(rawdata,aes(V8,V9,color=V9)) + geom_point()
for(i in 1:length(means))
{
p + (geom_segment(aes(x = rawdata[boundary[i],8], y = means[i], xend = rawdata[boundary[i],8], yend = means[i])))
}
Means是一个向量,包含迭代时每个不同边界的均值。
我没有收到任何错误,但细分未出现在情节中。
该脚本旨在根据数据集输入的大小进行扩展,因此for循环。