dgrtwo / tidy-text-mining

Manuscript of the book "Tidy Text Mining with R" by Julia Silge and David Robinson
http://tidytextmining.com
Other
1.32k stars 806 forks source link

Chapter 4: "promise already under evaluation" error #27

Closed petehobo closed 7 years ago

petehobo commented 7 years ago

Firstly, thanks for a great resource. I'm new to text mining, and am finding the text clear and enjoyable to work through.

When I try to run this code from chapter 4:

word_cors %>%
    filter(correlation > .15) %>%
    graph_from_data_frame() %>%
    ggraph(layout = "fr") +
    geom_edge_link(aes(edge_alpha = correlation), show.legend = FALSE) +
    geom_node_point(color = "lightblue", size = 5) +
    geom_node_text(aes(label = name), repel = TRUE) +
    theme_void()

I get the following error

Error in data.frame(x = xlim, y = ylim) : promise already under evaluation: recursive default argument reference or earlier problems?

It seems to come from this line:

geom_node_text(aes(label = name), repel = TRUE)

but more than that I can't tell (I'm fairly new to R).

For what it's worth, I get the same error when building the HTML version of the book locally.

If it's out of your hands, please let me know and I'll take it up with whichever package maintainer you feel is responsible.

In case it helps, here are the details of what I have installed:

> devtools::session_info()
Session info ---------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.3 (2017-03-06)
 system   x86_64, mingw32             
 ui       RStudio (1.0.136)           
 language (EN)                        
 collate  English_United Kingdom.1252 
 tz       Australia/Sydney            
 date     2017-04-16                  

Packages -------------------------------------------------------------------------------------------------------------------------
 package     * version    date       source                                  
 assertthat    0.2.0      2017-04-11 CRAN (R 3.3.3)                          
 broom         0.4.2      2017-02-13 CRAN (R 3.3.3)                          
 colorspace    1.3-2      2016-12-14 CRAN (R 3.3.3)                          
 DBI           0.6-1      2017-04-01 CRAN (R 3.3.3)                          
 devtools      1.12.0     2016-06-24 CRAN (R 3.3.3)                          
 digest        0.6.12     2017-01-27 CRAN (R 3.3.3)                          
 dplyr       * 0.5.0      2016-06-24 CRAN (R 3.3.3)                          
 foreign       0.8-67     2016-09-13 CRAN (R 3.3.3)                          
 ggforce       0.1.1      2016-11-28 CRAN (R 3.3.3)                          
 ggplot2     * 2.2.1      2016-12-30 CRAN (R 3.3.3)                          
 ggraph      * 1.0.0      2017-04-16 Github (thomasp85/ggraph@0d099f3)       
 ggrepel       0.6.9      2017-03-24 Github (slowkow/ggrepel@d21b468)        
 gridExtra     2.2.1      2016-02-29 CRAN (R 3.3.3)                          
 gtable        0.2.0      2016-02-26 CRAN (R 3.3.3)                          
 gutenbergr  * 0.1.2.9000 2017-04-14 Github (ropenscilabs/gutenbergr@26f0639)
 hms           0.3        2016-11-22 CRAN (R 3.3.3)                          
 igraph      * 1.0.1      2015-06-26 CRAN (R 3.3.0)                          
 janeaustenr * 0.1.4      2016-10-26 CRAN (R 3.3.3)                          
 labeling      0.3        2014-08-23 CRAN (R 3.3.2)                          
 lattice       0.20-35    2017-03-25 CRAN (R 3.3.3)                          
 lazyeval      0.2.0      2016-06-12 CRAN (R 3.3.3)                          
 magrittr      1.5        2014-11-22 CRAN (R 3.3.3)                          
 MASS          7.3-45     2016-04-21 CRAN (R 3.3.3)                          
 Matrix        1.2-8      2017-01-20 CRAN (R 3.3.3)                          
 memoise       1.0.0      2016-01-29 CRAN (R 3.3.3)                          
 mnormt        1.5-5      2016-10-15 CRAN (R 3.3.2)                          
 munsell       0.4.3      2016-02-13 CRAN (R 3.3.3)                          
 nlme          3.1-131    2017-02-06 CRAN (R 3.3.3)                          
 plyr          1.8.4      2016-06-08 CRAN (R 3.3.3)                          
 psych         1.7.3.21   2017-03-22 CRAN (R 3.3.3)                          
 purrr         0.2.2      2016-06-18 CRAN (R 3.3.3)                          
 R6            2.2.0      2016-10-05 CRAN (R 3.3.3)                          
 Rcpp          0.12.10    2017-03-19 CRAN (R 3.3.3)                          
 readr         1.1.0      2017-03-22 CRAN (R 3.3.3)                          
 reshape2      1.4.2      2016-10-22 CRAN (R 3.3.3)                          
 scales        0.4.1      2016-11-09 CRAN (R 3.3.3)                          
 SnowballC     0.5.1      2014-08-09 CRAN (R 3.3.2)                          
 stringi       1.1.5      2017-04-07 CRAN (R 3.3.3)                          
 stringr     * 1.2.0      2017-02-18 CRAN (R 3.3.3)                          
 tibble        1.3.0      2017-04-01 CRAN (R 3.3.3)                          
 tidyr       * 0.6.1      2017-01-10 CRAN (R 3.3.3)                          
 tidytext    * 0.1.2.900  2017-04-14 Github (juliasilge/tidytext@d4e3702)    
 tokenizers    0.1.4      2016-08-29 CRAN (R 3.3.3)                          
 tweenr        0.1.5      2016-10-10 CRAN (R 3.3.3)                          
 udunits2      0.13       2016-11-17 CRAN (R 3.3.2)                          
 units         0.4-3      2017-03-25 CRAN (R 3.3.3)                          
 viridis       0.4.0      2017-03-27 CRAN (R 3.3.3)                          
 viridisLite   0.2.0      2017-03-24 CRAN (R 3.3.3)                          
 widyr       * 0.0.0.9000 2017-04-13 Github (dgrtwo/widyr@58a1d2d)           
 withr         1.0.2      2016-06-20 CRAN (R 3.3.3)       
dgrtwo commented 7 years ago

I've gotten this same error recently: it's a problem that occurs when repel = TRUE in ggraph. The short term solution is to replace repel = TRUE with vjust = 1, hjust = 1- it won't look quite as good but it will certainly be readable.

If you'd like to open a GH issue on ggraph, here's a handy reproducible example:

library(ggraph)
library(igraph)
library(dplyr)

data_frame(node1 = 1:4, node2 = 2:5) %>%
  graph_from_data_frame() %>%
  ggraph(layout = "fr") +
  geom_edge_link() +
  geom_node_point() +
  geom_node_text(aes(label = name), repel = TRUE)

Incidentally, I've had a hard time figuring out which package causes it- ggplot2, ggraph, ggrepel, or something else- but ggraph is the safest bet for opening an issue.

petehobo commented 7 years ago

Excellent - thanks for the quick response. That workaround does the trick.

I've raised https://github.com/thomasp85/ggraph/issues/69, so am happy to close this

petehobo commented 7 years ago

Apparently this is fixed now (in https://github.com/slowkow/ggrepel/issues/72)