Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://had.co.nz/ggplot2/stat_smooth.html" rel="noreferrer"><code>stat_smooth</code></a> does produce output that you can use elsewhere, and with a slightly hacky way, you can put it into a variable in the global environment.</p> <p>You enclose the output variable in <code>..</code> on either side to use it. So if you add an <code>aes</code> in the <code>stat_smooth</code> call and use the global assign, <code>&lt;&lt;-</code>, to assign the output to a varible in the global environment you can get the the fitted values, or others - see below.</p> <pre><code>qplot(hp,wt,data=mtcars) + stat_smooth(aes(outfit=fit&lt;&lt;-..y..)) fit [1] 1.993594 2.039986 2.087067 2.134889 2.183533 2.232867 2.282897 2.333626 [9] 2.385059 2.437200 2.490053 2.543622 2.597911 2.652852 2.708104 2.764156 [17] 2.821771 2.888224 2.968745 3.049545 3.115893 3.156368 3.175495 3.181411 [25] 3.182252 3.186155 3.201258 3.235698 3.291766 3.353259 3.418409 3.487074 [33] 3.559111 3.634377 3.712729 3.813399 3.910849 3.977051 4.037302 4.091635 [41] 4.140082 4.182676 4.219447 4.250429 4.275654 4.295154 4.308961 4.317108 [49] 4.319626 4.316548 4.308435 4.302276 4.297902 4.292303 4.282505 4.269040 [57] 4.253361 4.235474 4.215385 4.193098 4.168621 4.141957 4.113114 4.082096 [65] 4.048910 4.013560 3.976052 3.936392 3.894586 3.850639 3.804557 3.756345 [73] 3.706009 3.653554 3.598987 3.542313 3.483536 3.422664 3.359701 3.294654 </code></pre> <p>The outputs you can obtain are:</p> <ul> <li><code>y</code>, predicted value</li> <li><code>ymin</code>, lower pointwise confidence interval around the mean</li> <li><code>ymax</code>, upper pointwise confidence interval around the mean </li> <li><code>se</code>, standard error</li> </ul> <p>Note that by default it predicts on 80 data points, which may not be aligned with your original data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload