0

I am creating a histogram for my itunes library, length of song (seconds), vs frequency. The graph is coming out nicely, but I can't plot a regression line over it without an error being returned.

    qplot(v10, xlab = "Length", ylab = "Frequency",
    main = "Length of Songs In my library", binwidth = 1, bins = 100 ) 

This returns a nice plot, when I add

    +  geom_smooth(method='lm + x^2')

I get errors. I have tried variations to get a regression line, all of them failing. I am thinking it might have something to do with my Y values being a frequency of x, and not having a column of its own in the data frame.

Gautam Savaliya
  • 1,403
  • 2
  • 20
  • 31
Emery
  • 31
  • 1
  • 8
  • please create a reproducable example for your question, refer to this post: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Bulat May 08 '16 at 18:56
  • 2
    Try using `method = 'lm', formula = 'whatever formula'` instead. – Gopala May 08 '16 at 18:58
  • inside of the geom_smooth, or qplot? and what do you mean by 'whatever formula'...? – Emery May 08 '16 at 19:14
  • `+ stat_smooth(method = 'lm', formula=y~x+I(x^2))` or `formula = y ~ poly(x, 2)` – B Williams May 10 '16 at 21:41

0 Answers0