Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"sum_" function missing for geom_sankey_bump() #3

Closed
engineerchange opened this issue Apr 4, 2021 · 2 comments
Closed

"sum_" function missing for geom_sankey_bump() #3

engineerchange opened this issue Apr 4, 2021 · 2 comments

Comments

@engineerchange
Copy link
Contributor

Following the sum_ issue reported in #1, I have the same issue with the example provided in the readme.

I tried:

library(ggsankey)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(ggplot2)
library(gapminder)

df <- gapminder %>%
    group_by(continent, year) %>%
    summarise(gdp = (sum_(pop * gdpPercap)/1e9) %>% round(0), .groups = "keep") %>%
    ungroup()
#> Error: Problem with `summarise()` input `gdp`.
#> x could not find function "sum_"
#> ℹ Input `gdp` is `(sum_(pop * gdpPercap)/1e+09) %>% round(0)`.
#> ℹ The error occurred in group 1: continent = "Africa", year = 1952.

ggplot(df, aes(x = year,
               node = continent,
               fill = continent,
               value = gdp)) +
    geom_sankey_bump(space = 0, type = "alluvial", color = "transparent", smooth = 6) +
    scale_fill_viridis_d(option = "A", alpha = .8) +
    theme_sankey_bump(base_size = 16) +
    labs(x = NULL,
         y = "GDP ($ bn)",
         fill = NULL,
         color = NULL) +
    theme(legend.position = "bottom") +
    labs(title = "GDP development per continent")
#> Error:   You're passing a function as global data.
#>   Have you misspelled the `data` argument in `ggplot()`

Created on 2021-04-03 by the reprex package (v1.0.0)

I also tried removing sum_ and replacing with sum when writing to the variable df, but I also had no luck.

See here:

df <- gapminder %>%
  group_by(continent, year) %>%
  summarise(gdp = (sum(pop * gdpPercap)/1e9) %>% round(0), .groups = "keep") %>%
  ungroup()

ggplot(df, aes(x = year,
               node = continent,
               fill = continent,
               value = gdp)) +
  geom_sankey_bump(space = 0, type = "alluvial", color = "transparent", smooth = 6) +
  scale_fill_viridis_d(option = "A", alpha = .8) +
  theme_sankey_bump(base_size = 16) +
  labs(x = NULL,
       y = "GDP ($ bn)",
       fill = NULL,
       color = NULL) +
  theme(legend.position = "bottom") +
  labs(title = "GDP development per continent")

My console error is different than reprex's for some reason; this is my console error:

Error: Problem with `summarise()` input `flow_freq`.
x could not find function "sum_"
ℹ Input `flow_freq` is `sum_(value)`.
ℹ The error occurred in group 1: n_x = 1952, node = "Oceania 1952", n_next_x = 1957, next_node = "Oceania 1957".
@chalg
Copy link

chalg commented Apr 6, 2021

Was about the raise the same issue.

@davidsjoberg
Copy link
Owner

Thanks! It was problem with my use of my own sum_ function from hablar ;) Now I've removed that dependency and it should work fine!

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

No branches or pull requests

3 participants