ggplotly returns group_by_ error for ggplot with undefined dataframe
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the two ggplotly examples from the issue and compare the successful and failing cases. Trace the ggplotly handling of the inline aes mappings and the group value represented by waiver. Done means both examples render without the group_by_ error while preserving the grouped line behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100