Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

no applicable method for 'group_by_' applied to an object of class "ggvis" #474

Open
maspotts opened this issue Jun 21, 2017 · 3 comments
Open

Comments

@maspotts
Copy link

I have run into an unexpected problem when including a call to ggvis::group_by in a library I'm building. This is the offending code:

x %>% gather(key, value, -x) %>% bind_rows(s) %>% ggvis(~x, ~value) %>%
         layer_points(fill=~key) %>% group_by(key) %>% layer_paths(stroke=~key)

and it works great if I paste it directly into my R shell. But when I build it into a library, using:

 #' @importFrom ggvis ggvis layer_points layer_paths group_by

and then try to execute that code I get this error:

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

I see that ggvis::group_by is just UseMethod("group_by") in the dplyr namespace. I've tried importing group_by (and even also group_by_) from dplyr, but nothing helped. I'm at a loss to understand what I'm doing wrong, or conceivably I've found a bug? I did find references to this error message being due to a long-fixed bug in ggvis (6c1ebbe), which appears to add group_by_ as an export in ggvis' namespace.

I've replicated this problem under the latest ggvis (0.4.3) and both dplyr 0.5.0 and 0.7.0.

Any help will be gratefully appreciated!

@hadley
Copy link
Member

hadley commented Jun 22, 2017

I suspect the problem is that ggvis isn't exporting the group_by_ method.

@maspotts
Copy link
Author

maspotts commented Jun 22, 2017 via email

@maspotts
Copy link
Author

I had a poke around in the ggvis source code, and I can't find a group_by_ function. It defines group_by_.ggvis and group_by_.reactive (both wrap around dplyr::group_by_ ) and exports them both, but no group_by_ . I managed to get rid of the error by replacing group_by(key) with group_by_.ggvis("key"). Still don't understand why that's only necessary when calling it from my own package though!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants