r - Adding a custom-range ab/smooth line to ggplot -


Is there any way to limit the data limit of an align or smooth line in the GG Plot? For example exponential distribution data occasionally have significant lead outlines, as well as a long but quite non-interesting tail:

  d = sort (rexp (100, rate = 1) ), Decreasing = t) Ggplot (null, aes (1: length (d), d)) + gom_point () + scale_y_log10 () + geom_smooth (method = lm, f = f)  

Enter image details here

The blue line is ggplot, and red I I've added the GOM_smoon Funk in an X-Range to show the line Connection may add a forced 12-80 - is to show the general domain of examples which may exist between the extreme points in the specific cases and accounting for the long tail.

Try this:

  Library (GG Plot 2) Set.seed (1) D & LT; - Sort (Repex (100, Rate = 1), Lowering = T) GG & LT; - data.frame (x = 1: length (d), y = d) ggplot (gg, aes (x, y)) + geom_point () + scale_y_log10 () + geom_smooth (data = gg [gg $ x> 11 & amp; gg $ x & lt; 81,], method = Lm, from = F)  


Comments