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

geom_flow() alignment issue #64

Closed
jrhaight opened this issue Aug 6, 2020 · 7 comments
Closed

geom_flow() alignment issue #64

jrhaight opened this issue Aug 6, 2020 · 7 comments
Labels

Comments

@jrhaight
Copy link

jrhaight commented Aug 6, 2020

Rplot_works
Rplot_not_working

Description of the issue

I seem to have run across an alignment issue in the updated version 0.12. This seems to be happening when there is missingness immediately after the first change in x-value.

For example, in the data(majors), if I were to set all curriculum to missing for student 1, after curr1, it seems to cause alignment issues in the output, but only when there are no options set to geom_flow.

Example with some missingness immediately after CURR1 for student 1:

df_na_after_curr1 <- majors %>% 
  mutate(curriculum = if_else(student == 1 & semester != "CURR1", NA_character_, as.character(curriculum)),
         curriculum = as.factor(curriculum))

In my example, going from CURR1 to CURR3, student 14 should move from ceramic to ceramic. The "memoryless" version where there are no options set to geom_flow (object named: not_working) is askew, and not showing someone going from ceramic at curr1 to ceramic at curr3.

Am new to submitting these reports, so I hope this made sense.

Reproducible example

library(dplyr)
library(ggalluvial)
data(majors)
majors$curriculum <- as.factor(majors$curriculum)

df_na_after_curr1 <- majors %>% 
  mutate(curriculum = if_else(student == 1 & semester != "CURR1", NA_character_, as.character(curriculum)),
         curriculum = as.factor(curriculum))


works <- ggplot(df_na_after_curr1,
                aes(x = semester, stratum = curriculum, alluvium = student,
                    fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow(stat = "alluvium", lode.guidance = "frontback",
            color = "darkgray") +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")

not_working <- ggplot(df_na_after_curr1,
                      aes(x = semester, stratum = curriculum, alluvium = student,
                          fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow() +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")

works 
not_working
@corybrunson
Copy link
Owner

@snootsuitriot thank you for raising the issue! You have described it just fine—i can see clearly from your images what you mean. Curiously, i am unable to reproduce the problem. So i'd like to ask if you could wrap up your example using the reprex package.

Here's what i get when i run your code, which i've used reprex to wrap up. I've also added a sessionInfo() call at the bottom, to reveal what versions of packages i have installed that are being used somehow. If you could do the same thing with your code (and include a sessionInfo() call), then it may help identify the discrepancy.

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(ggalluvial)
#> Warning: package 'ggalluvial' was built under R version 4.0.2
#> Loading required package: ggplot2
data(majors)
majors$curriculum <- as.factor(majors$curriculum)

df_na_after_curr1 <- majors %>% 
  mutate(curriculum = if_else(student == 1 & semester != "CURR1", NA_character_, as.character(curriculum)),
         curriculum = as.factor(curriculum))

works <- ggplot(df_na_after_curr1,
                aes(x = semester, stratum = curriculum, alluvium = student,
                    fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow(stat = "alluvium", lode.guidance = "frontback",
            color = "darkgray") +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")

not_working <- ggplot(df_na_after_curr1,
                      aes(x = semester, stratum = curriculum, alluvium = student,
                          fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow() +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")

works 

not_working

df_na_after_curr1 <- majors %>% 
  mutate(curriculum = if_else(student == 1 & semester != "CURR1", NA_character_, as.character(curriculum)),
         curriculum = as.factor(curriculum))

sessionInfo()
#> R version 4.0.0 (2020-04-24)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS High Sierra 10.13.6
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggalluvial_0.12.0 ggplot2_3.3.2     dplyr_1.0.1      
#> 
#> loaded via a namespace (and not attached):
#>  [1] knitr_1.29         magrittr_1.5       munsell_0.5.0      tidyselect_1.1.0  
#>  [5] colorspace_1.4-1   R6_2.4.1           rlang_0.4.7        stringr_1.4.0     
#>  [9] highr_0.8          tools_4.0.0        grid_4.0.0         gtable_0.3.0      
#> [13] xfun_0.15          withr_2.2.0        htmltools_0.5.0    ellipsis_0.3.1    
#> [17] yaml_2.2.1         digest_0.6.25      tibble_3.0.3.9000  lifecycle_0.2.0   
#> [21] crayon_1.3.4       farver_2.0.3       RColorBrewer_1.1-2 tidyr_1.1.1       
#> [25] purrr_0.3.4        vctrs_0.3.2        glue_1.4.1         evaluate_0.14     
#> [29] rmarkdown_2.3      labeling_0.3       stringi_1.4.6      compiler_4.0.0    
#> [33] pillar_1.4.6       scales_1.1.1       generics_0.0.2     pkgconfig_2.0.3

Created on 2020-08-05 by the reprex package (v0.3.0)

@jrhaight
Copy link
Author

jrhaight commented Aug 6, 2020

I think I messed up saving the first reprex(), but long story short, I updated R and reinstalled packages, and it now runs correctly with no issues. So it seems an outdated R version will do this, most likely?

sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Los_Angeles         
#>  date     2020-08-05                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version    date       lib source                           
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 3.6.1)                   
#>  cli            2.0.2      2020-02-28 [1] CRAN (R 3.6.3)                   
#>  colorspace     1.4-1      2019-03-18 [1] CRAN (R 3.6.1)                   
#>  crayon         1.3.4      2017-09-16 [1] CRAN (R 3.6.1)                   
#>  curl           4.3        2019-12-02 [1] CRAN (R 3.6.2)                   
#>  digest         0.6.25     2020-02-23 [1] CRAN (R 3.6.3)                   
#>  dplyr        * 1.0.1      2020-07-31 [1] CRAN (R 3.6.3)                   
#>  ellipsis       0.3.1      2020-05-15 [1] CRAN (R 3.6.3)                   
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 3.6.1)                   
#>  fansi          0.4.1      2020-01-08 [1] CRAN (R 3.6.2)                   
#>  farver         2.0.3      2020-01-16 [1] CRAN (R 3.6.3)                   
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 3.6.3)                   
#>  generics       0.0.2      2018-11-29 [1] CRAN (R 3.6.1)                   
#>  ggalluvial   * 0.12.0     2020-07-14 [1] CRAN (R 3.6.3)                   
#>  ggplot2      * 3.3.2      2020-06-19 [1] CRAN (R 3.6.3)                   
#>  glue           1.4.1      2020-05-13 [1] CRAN (R 3.6.3)                   
#>  gtable         0.3.0      2019-03-25 [1] CRAN (R 3.6.1)                   
#>  highr          0.8        2019-03-20 [1] CRAN (R 3.6.1)                   
#>  htmltools      0.5.0      2020-06-16 [1] CRAN (R 3.6.3)                   
#>  httr           1.4.2      2020-07-20 [1] CRAN (R 3.6.3)                   
#>  knitr          1.29       2020-06-23 [1] CRAN (R 3.6.3)                   
#>  labeling       0.3        2014-08-23 [1] CRAN (R 3.6.0)                   
#>  lifecycle      0.2.0      2020-03-06 [1] CRAN (R 3.6.3)                   
#>  magrittr       1.5        2014-11-22 [1] CRAN (R 3.6.1)                   
#>  mime           0.9        2020-02-04 [1] CRAN (R 3.6.2)                   
#>  munsell        0.5.0      2018-06-12 [1] CRAN (R 3.6.1)                   
#>  pillar         1.4.6      2020-07-10 [1] CRAN (R 3.6.3)                   
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 3.6.1)                   
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 3.6.3)                   
#>  R6             2.4.1      2019-11-12 [1] CRAN (R 3.6.2)                   
#>  RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 3.6.0)                   
#>  reprex         0.3.0.9001 2020-08-06 [1] Github (tidyverse/reprex@d898823)
#>  rlang          0.4.7      2020-07-09 [1] CRAN (R 3.6.3)                   
#>  rmarkdown      2.3        2020-06-18 [1] CRAN (R 3.6.3)                   
#>  rstudioapi     0.11       2020-02-07 [1] CRAN (R 3.6.3)                   
#>  scales         1.1.1      2020-05-11 [1] CRAN (R 3.6.1)                   
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 3.6.1)                   
#>  stringi        1.4.6      2020-02-17 [1] CRAN (R 3.6.2)                   
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 3.6.1)                   
#>  tibble         3.0.3      2020-07-10 [1] CRAN (R 3.6.3)                   
#>  tidyr          1.1.1      2020-07-31 [1] CRAN (R 3.6.3)                   
#>  tidyselect     1.1.0      2020-05-11 [1] CRAN (R 3.6.3)                   
#>  vctrs          0.3.2      2020-07-15 [1] CRAN (R 3.6.3)                   
#>  withr          2.2.0      2020-04-20 [1] CRAN (R 3.6.3)                   
#>  xfun           0.16       2020-07-24 [1] CRAN (R 3.6.3)                   
#>  xml2           1.3.2      2020-04-23 [1] CRAN (R 3.6.3)                   
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 3.6.3)                   
#> 

WORKING session info below:

sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Los_Angeles         
#>  date     2020-08-05                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version    date       lib source                           
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.0.2)                   
#>  cli            2.0.2      2020-02-28 [1] CRAN (R 4.0.2)                   
#>  colorspace     1.4-1      2019-03-18 [1] CRAN (R 4.0.2)                   
#>  crayon         1.3.4      2017-09-16 [1] CRAN (R 4.0.2)                   
#>  curl           4.3        2019-12-02 [1] CRAN (R 4.0.2)                   
#>  digest         0.6.25     2020-02-23 [1] CRAN (R 4.0.2)                   
#>  dplyr        * 1.0.1      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  ellipsis       0.3.1      2020-05-15 [1] CRAN (R 4.0.2)                   
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.0.2)                   
#>  fansi          0.4.1      2020-01-08 [1] CRAN (R 4.0.2)                   
#>  farver         2.0.3      2020-01-16 [1] CRAN (R 4.0.2)                   
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  generics       0.0.2      2018-11-29 [1] CRAN (R 4.0.2)                   
#>  ggalluvial   * 0.12.0     2020-07-14 [1] CRAN (R 4.0.2)                   
#>  ggplot2      * 3.3.2      2020-06-19 [1] CRAN (R 4.0.2)                   
#>  glue           1.4.1      2020-05-13 [1] CRAN (R 4.0.2)                   
#>  gtable         0.3.0      2019-03-25 [1] CRAN (R 4.0.2)                   
#>  highr          0.8        2019-03-20 [1] CRAN (R 4.0.2)                   
#>  htmltools      0.5.0      2020-06-16 [1] CRAN (R 4.0.2)                   
#>  httr           1.4.2      2020-07-20 [1] CRAN (R 4.0.2)                   
#>  knitr          1.29       2020-06-23 [1] CRAN (R 4.0.2)                   
#>  labeling       0.3        2014-08-23 [1] CRAN (R 4.0.0)                   
#>  lifecycle      0.2.0      2020-03-06 [1] CRAN (R 4.0.2)                   
#>  magrittr       1.5        2014-11-22 [1] CRAN (R 4.0.2)                   
#>  mime           0.9        2020-02-04 [1] CRAN (R 4.0.0)                   
#>  munsell        0.5.0      2018-06-12 [1] CRAN (R 4.0.2)                   
#>  pillar         1.4.6      2020-07-10 [1] CRAN (R 4.0.2)                   
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.0.2)                   
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.0.2)                   
#>  R6             2.4.1      2019-11-12 [1] CRAN (R 4.0.2)                   
#>  RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 4.0.0)                   
#>  reprex         0.3.0.9001 2020-08-06 [1] Github (tidyverse/reprex@d898823)
#>  rlang          0.4.7      2020-07-09 [1] CRAN (R 4.0.2)                   
#>  rmarkdown      2.3        2020-06-18 [1] CRAN (R 4.0.2)                   
#>  rstudioapi     0.11       2020-02-07 [1] CRAN (R 4.0.2)                   
#>  scales         1.1.1      2020-05-11 [1] CRAN (R 4.0.2)                   
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 4.0.2)                   
#>  stringi        1.4.6      2020-02-17 [1] CRAN (R 4.0.0)                   
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.0.2)                   
#>  tibble         3.0.3      2020-07-10 [1] CRAN (R 4.0.2)                   
#>  tidyr          1.1.1      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  tidyselect     1.1.0      2020-05-11 [1] CRAN (R 4.0.2)                   
#>  vctrs          0.3.2      2020-07-15 [1] CRAN (R 4.0.2)                   
#>  withr          2.2.0      2020-04-20 [1] CRAN (R 4.0.2)                   
#>  xfun           0.16       2020-07-24 [1] CRAN (R 4.0.2)                   
#>  xml2           1.3.2      2020-04-23 [1] CRAN (R 4.0.2)                   
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.0.2)   

@corybrunson
Copy link
Owner

Oh, possibly—a ggalluvial dependency forced me to upgrade the dependency to R v3.5, but that shouldn't've caused a discrepancy between your v3.6 and v4.0. The first place i look is tidyr, but your versions seem to have been the same in both cases. I'm sorry i can't be of more help with diagnosis, but i'm glad the issue is resolved!

@jrhaight
Copy link
Author

jrhaight commented Aug 6, 2020

I'm not sure if I should submit a new issue, and maybe this just isn't how these data should be formatted.... but let's say I filtered out all missing data using r filter(!is.na(curriculum). The output is then still offset for me, example below as follows.

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(ggalluvial)
#> Loading required package: ggplot2
data(majors)
majors$curriculum <- as.factor(majors$curriculum)

df_na_after_curr1 <- majors %>% 
  mutate(curriculum = if_else(student == 1 & semester != "CURR1", NA_character_, as.character(curriculum)),
         curriculum = as.factor(curriculum)) %>% 
  filter(!is.na(curriculum))


works <- ggplot(df_na_after_curr1,
                aes(x = semester, stratum = curriculum, alluvium = student,
                    fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow(stat = "alluvium", lode.guidance = "frontback",
            color = "darkgray") +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")

not_working <- ggplot(df_na_after_curr1,
                      aes(x = semester, stratum = curriculum, alluvium = student,
                          fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow() +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")

works 

not_working

Created on 2020-08-06 by the reprex package (v0.3.0.9001)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Los_Angeles         
#>  date     2020-08-06                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version    date       lib source                           
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.0.2)                   
#>  cli            2.0.2      2020-02-28 [1] CRAN (R 4.0.2)                   
#>  colorspace     1.4-1      2019-03-18 [1] CRAN (R 4.0.2)                   
#>  crayon         1.3.4      2017-09-16 [1] CRAN (R 4.0.2)                   
#>  curl           4.3        2019-12-02 [1] CRAN (R 4.0.2)                   
#>  digest         0.6.25     2020-02-23 [1] CRAN (R 4.0.2)                   
#>  dplyr        * 1.0.1      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  ellipsis       0.3.1      2020-05-15 [1] CRAN (R 4.0.2)                   
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.0.2)                   
#>  fansi          0.4.1      2020-01-08 [1] CRAN (R 4.0.2)                   
#>  farver         2.0.3      2020-01-16 [1] CRAN (R 4.0.2)                   
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  generics       0.0.2      2018-11-29 [1] CRAN (R 4.0.2)                   
#>  ggalluvial   * 0.12.0     2020-07-14 [1] CRAN (R 4.0.2)                   
#>  ggplot2      * 3.3.2      2020-06-19 [1] CRAN (R 4.0.2)                   
#>  glue           1.4.1      2020-05-13 [1] CRAN (R 4.0.2)                   
#>  gtable         0.3.0      2019-03-25 [1] CRAN (R 4.0.2)                   
#>  highr          0.8        2019-03-20 [1] CRAN (R 4.0.2)                   
#>  htmltools      0.5.0      2020-06-16 [1] CRAN (R 4.0.2)                   
#>  httr           1.4.2      2020-07-20 [1] CRAN (R 4.0.2)                   
#>  knitr          1.29       2020-06-23 [1] CRAN (R 4.0.2)                   
#>  labeling       0.3        2014-08-23 [1] CRAN (R 4.0.0)                   
#>  lifecycle      0.2.0      2020-03-06 [1] CRAN (R 4.0.2)                   
#>  magrittr       1.5        2014-11-22 [1] CRAN (R 4.0.2)                   
#>  mime           0.9        2020-02-04 [1] CRAN (R 4.0.0)                   
#>  munsell        0.5.0      2018-06-12 [1] CRAN (R 4.0.2)                   
#>  pillar         1.4.6      2020-07-10 [1] CRAN (R 4.0.2)                   
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.0.2)                   
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.0.2)                   
#>  R6             2.4.1      2019-11-12 [1] CRAN (R 4.0.2)                   
#>  RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 4.0.0)                   
#>  reprex         0.3.0.9001 2020-08-06 [1] Github (tidyverse/reprex@d898823)
#>  rlang          0.4.7      2020-07-09 [1] CRAN (R 4.0.2)                   
#>  rmarkdown      2.3        2020-06-18 [1] CRAN (R 4.0.2)                   
#>  rstudioapi     0.11       2020-02-07 [1] CRAN (R 4.0.2)                   
#>  scales         1.1.1      2020-05-11 [1] CRAN (R 4.0.2)                   
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 4.0.2)                   
#>  stringi        1.4.6      2020-02-17 [1] CRAN (R 4.0.0)                   
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.0.2)                   
#>  tibble         3.0.3      2020-07-10 [1] CRAN (R 4.0.2)                   
#>  tidyr          1.1.1      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  tidyselect     1.1.0      2020-05-11 [1] CRAN (R 4.0.2)                   
#>  vctrs          0.3.2      2020-07-15 [1] CRAN (R 4.0.2)                   
#>  withr          2.2.0      2020-04-20 [1] CRAN (R 4.0.2)                   
#>  xfun           0.16       2020-07-24 [1] CRAN (R 4.0.2)                   
#>  xml2           1.3.2      2020-04-23 [1] CRAN (R 4.0.2)                   
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.0.2)                   
#> 
#> [1] C:/Users/john/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library

@corybrunson
Copy link
Owner

@jrhaight thank you for following up! I can reproduce this issue, and below is a more or less minimal version of it. This needs to be fixed, and i'll have a look as soon as i can find time.

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(ggalluvial)
#> Warning: package 'ggalluvial' was built under R version 4.0.2
#> Loading required package: ggplot2

test <- data.frame(
  student = c(14L, 9L, 14L, 9L),
  semester = factor(c("CURR1", "CURR3", "CURR3", "CURR5")),
  curriculum = factor(c("Ceramic", "Art History", "Ceramic", "Art History"))
)
ggplot(test,
       aes(x = semester, stratum = curriculum, alluvium = student,
           fill = curriculum, label = curriculum)) +
  geom_flow() +
  geom_stratum()

Created on 2020-08-06 by the reprex package (v0.3.0)

@corybrunson corybrunson reopened this Aug 6, 2020
@corybrunson corybrunson added the bug label Aug 7, 2020
@corybrunson
Copy link
Owner

Hi @jrhaight i think i've got a solution in the issue-64 branch. I assume that this problem arose for you in a larger setting, so i wonder if you could see if the fix works for you in that setting? You should be able to install it like so:

remotes::install_github("corybrunson/ggalluvial", ref = "issue-64")

The problem was that i'd ignored my own notes and dropped missing values in the stat_flow() computation that corresponded to lodes without flows; basically, i pulled the flowless lodes out from under the above flows, and they all piled up without those gaps.

@jrhaight
Copy link
Author

jrhaight commented Aug 8, 2020

Installed, and that fixed the problem in my setting. Excellent, thanks!

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

No branches or pull requests

2 participants