Please keep the list copied.
On Fri, Sep 29, 2017 at 10:10 AM, Vikram Rawat <
vikram...@gmail.com> wrote:
> I tried but this does not work.
Right, I forgot that formula needs to be in terms of x and y. Ugh.
My point is if I want to try regression
> analysis. I will do so by building a model. Either lm or gam or speedlm but
> I will build my own model and compare them with other one.
>
> Now when I want to pass it to base plot I can simply do that with abline
> function butI can't do that straight away in ggplot2.
>
> What's the alternative method to pass the model directly. Without any
> changes.
I don't really understand the question. My guess is that you want something like
model<- lm(mpg~hp,mtcars)
mtcars %>%
ggplot(aes(hp, mpg))+
geom_point() +
geom_abline(intercept = coef(model)[1], slope = coef(model)[2])
or perhaps
mtcars %>%
ggplot(aes(hp, mpg))+
geom_point() +
geom_line(aes(y = fitted(model)))
>
> My question is can we do it?? If so then how?
>
> Please do answer it if you know...
>
> 29-09-2017 6:55 pm को "Vikram Rawat" <
vikram...@gmail.com> ने लिखा:
>
>> Cool, thanks!
>>
>> 29-09-2017 5:59 pm को "Ista Zahn" <
ista...@gmail.com> ने लिखा:
>>>
>>> One option is something like
>>>
>>> geom_smooth(method = lm, formula = formula(model))
>>>
>>> This does however re-fit the model.
>>> To unsubscribe: email
ggplot2+u...@googlegroups.com
>>> More options:
http://groups.google.com/group/ggplot2
>>>
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "ggplot2" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to
ggplot2+u...@googlegroups.com.