ggplot2 - Regrresion line without smoot?

10 views
Skip to first unread message

Avner Kantor

unread,
Nov 17, 2016, 4:49:10 AM11/17/16
to israel-r-user-group

Currently on dev version of ggplot2 and plotly geom_smooth does not work:

library(dplyr)
library(ggplot2)
library(plotly)
g <- data.frame(x=c(23.2,22.8),y=c(17.7,16.3),company=c('a','b')) %>%
    ggplot(aes(x=x,y=y,text=company)) +
    geom_point() +
    geom_smooth()
ggplotly(g, tooltip='text')

This bug didn't fix yet. I wonder if there is other ggplot2 way to create regreesion line. Do you have any idea?

Thanks,

Avner


Tal Galili

unread,
Nov 17, 2016, 3:11:36 PM11/17/16
to israel-r-...@googlegroups.com
דיווחת על הבאג בגיטהב?

Sent from a smart-phone
--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

amit gal

unread,
Nov 17, 2016, 4:27:41 PM11/17/16
to israel-r-...@googlegroups.com
it would be nice to see the error message. and the exact version of the packages you use. your example seem to not work due to laziness in creating the artificial data. with only 2 rows, splitting the data into 2 companies (one point per company) I wouldn't be able to do geom_smooth() regardless of bugs in the code - simply, there is no solution to that. It doesn't work on my computer, but once you add a few rows to the dataset it works perfectly. (ggplot2 2.2.0, plotly 4.5.6)


--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.

Avner Kantor

unread,
Nov 18, 2016, 2:05:26 AM11/18/16
to israel-r-user-group
טל-הבאג כבר דווח בגיטהאב לפני מספר שבועות. קיוויתי שהוא יתוקן בעדכונון האחרון אבל הוא עדיין פתוח.

עמית-הנה בשבילך הודעת השגיאה
Error in `$<-.data.frame`(`*tmp*`, "alpha", value = 1) : 
  replacement has 1 row, data has 0

בכל מקרה תהיתי
 אם smooth הוא הדרך היחידה לייצר קווי רגרסיה ב-ggplot2. לא מצאתי דרך אחרת. מסתבר שליצור תחליף לפונקציית הרגרסיה הנהדרת של ggplot לוקח יותר מכמה שורות. בסופו של דבר הפתרון שלי הוא לוותר על plotly בגרף זה (מה שגם חוסך זמן טעינה אז בכלל מושלם).

To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

amit gal

unread,
Nov 18, 2016, 2:19:33 AM11/18/16
to israel-r-...@googlegroups.com

הודעה קךאסית של "אין מספיק נתונים" נסה להריץ עם יותר נתונים בכל קבוצה. כמו כן אפשר להשתמש ב geom_abline כשבשורה שלפני תריץ רגרסיה לינארית בעצמך.


בתאריך 18 בנוב׳ 2016 9:05,‏ "Avner Kantor" <avner...@gmail.com> כתב:

Avner Kantor

unread,
Nov 18, 2016, 2:25:37 AM11/18/16
to israel-r-user-group
זו גם הודעת שגיאה קלאסית ש-ggplot2 קורס מסיבה לא ידועה.
Reply all
Reply to author
Forward
0 new messages