0

I'm having difficulty adding some trend lines to a graph.

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 is a vector containing the means for each different boundary as it iterates through.

I'm not getting any errors, but the segments aren't showing up on the plot.

The script is designed to be scale-able depending on the size of the data set input, hence the for loop.

  • Please consider providing sample data. – russellpierce Jan 25 '17 at 22:18
  • 2
    `ggplot2`doesn't really like to work this way. It prefers every variable to be contained in it's own column. Post some representative data, and maybe you'll get some useful advice. See this link for useful advice about asking questions [Asking questions](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) –  Jan 25 '17 at 22:19
  • agree with @user127649. The base package is much easier to use with regard to your question. – David C. Jan 26 '17 at 03:01

0 Answers0