Re: ggplot Multiple Regression Lines

82 views
Skip to first unread message

Hadley Wickham

unread,
Jan 26, 2017, 2:13:02 PM1/26/17
to Timothy Lau, ggplot2
You've given each woman a unique identifier so there is only one data
point per person. It's hard to fit a line to one point ;)

Hadley

On Thu, Jan 26, 2017 at 12:56 PM, Timothy Lau <timoth...@gmail.com> wrote:
> Hi,
>
> I'm trying to make a single plot with multiple regression lines.
> This code example doesn't work.
>
>
> women2 <- data.frame(id = 1:nrow(women), women)
> ggplot(data = women2, mapping = aes(x = height, y = weight, group = id)) +
> geom_smooth(method = lm, se = F)
>
> What should I change?
>
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> 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.
> For more options, visit https://groups.google.com/d/optout.



--
http://hadley.nz

Brian

unread,
Jan 26, 2017, 2:14:08 PM1/26/17
to ggp...@googlegroups.com, Timothy Lau
I am guessing you have too many "group"s. "id" should be a meaningful factor with which one can perform a regression. This example is not reproducible so I/we can't help you much further (if I have helped you at all).

Timothy Lau

unread,
Jan 26, 2017, 2:27:29 PM1/26/17
to Hadley Wickham, ggplot2

--


Best,
Timothy

Reply all
Reply to author
Forward
0 new messages