plotly / plotly/plotly.R

ggplotly returns group_by_ error for ggplot with undefined dataframe

Offen
#1,682 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
R
Sterne
2.7k
Forks
641
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

The following ggplot2 command fails when executed in ggplotly:

ggplot()+geom_line(aes(x = c(1,2,3,4), y = c(1,2,3,4), group = c(1,1,2,2))) #works

ggplotly(ggplot()+geom_line(aes(x = c(1,2,3,4), y = c(1,2,3,4), group = c(1,1,2,2)))) #fails

#>Error in UseMethod("group_by_") : 
#> no applicable method for 'group_by_' applied to an object of class "waiver"

This error can be addressed by assigning the data to a data frame and explicitly mapping the variables to the data frame within the ggplot call:

 df <- data.frame(x = c(1,2,3,4), y = c(1,2,3,4), group = c(1,1,2,2))

ggplotly(ggplot()+geom_line(data = df, aes(x = x, y = y, group = group))) #works 

ggplotly(ggplot()+geom_line(aes(x = df$x, y = df$y, group = df$group))) #fails

#>Error in UseMethod("group_by_") : 
#> no applicable method for 'group_by_' applied to an object of class "waiver"

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die beiden ggplotly-Beispiele aus dem Issue auszuführen und die erfolgreichen und fehlschlagenden Fälle zu vergleichen. Verfolge, wie ggplotly die Inline-aes-Zuordnungen und den durch waiver dargestellten group-Wert verarbeitet. Die Aufgabe ist erledigt, wenn beide Beispiele ohne den group_by_-Fehler gerendert werden und dabei das Verhalten der gruppierten Linien erhalten bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.