lepennec / ggwordcloud

A word cloud geom for ggplot2
https://lepennec.github.io/ggwordcloud/
GNU General Public License v3.0
172 stars 8 forks source link

Error when using ggwordcloud inside of Shiny application #9

Closed erichare closed 5 years ago

erichare commented 5 years ago

Here is a minimal shiny app, using one of the test examples in a renderPlot expression.

library(shiny)
library(ggwordcloud)

data("love_words_small")

set.seed(42)

ui <- fluidPage(

    titlePanel("GGWordCloud Test"),

    sidebarLayout(
        sidebarPanel(
        ),

        mainPanel(
           plotOutput("wc")
        )
    )
)

server <- function(input, output) {

    output$wc <- renderPlot({
        ggplot(love_words_small, aes(label = word, size = speakers)) +
            geom_text_wordcloud() +
            scale_size_area(max_size = 24) +
            theme_minimal()
    })
}

shinyApp(ui = ui, server = server)

This produces:

Warning: Error in [: subscript out of bounds

Any ideas? This is using R 3.6, and the latest CRAN versions of both Shiny (1.3.2) and ggwordcloud (0.4.0)

lepennec commented 5 years ago

Works for me with R 3.5. Do you have the same error when using geom_text?

erichare commented 5 years ago

It works fine for me with geom_text, yes - here's a very slight modification that runs successfully for me:

library(shiny)
library(ggwordcloud)

data("love_words_small")

set.seed(42)

ui <- fluidPage(

    titlePanel("GGWordCloud Test"),

    sidebarLayout(
        sidebarPanel(
        ),

        mainPanel(
            plotOutput("wc")
        )
    )
)

server <- function(input, output) {

    output$wc <- renderPlot({
        ggplot(love_words_small, aes(x = 1, y = 1, label = word, size = speakers)) +
            geom_text() +
            scale_size_area(max_size = 24) +
            theme_minimal()
    })
}

shinyApp(ui = ui, server = server)

I didn't think it had to do with the R version, because I have a linux server with 3.5.3 that's also now exhibiting the same error (it used to work fine) - so my assumption was it was maybe due to a Shiny update or some other package dependency. But if it works for you with the same package versions then I'm really not sure...

lepennec commented 5 years ago

Thank you. I'm going to investigate...

lepennec commented 5 years ago

Can you show me the output of

sessioninfo::session_info()

?

I have tested your code on my Windows system without any issue...

erichare commented 5 years ago

Sure, here it is:

─ Session info ─────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       macOS Mojave 10.14.5        
 system   x86_64, darwin18.5.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2019-05-30                  

─ Packages ─────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source        
 assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.6.0)
 cli           1.1.0   2019-03-19 [1] CRAN (R 3.6.0)
 colorspace    1.4-1   2019-03-18 [1] CRAN (R 3.6.0)
 crayon        1.3.4   2017-09-16 [1] CRAN (R 3.6.0)
 digest        0.6.19  2019-05-20 [1] CRAN (R 3.6.0)
 dplyr         0.8.1   2019-05-14 [1] CRAN (R 3.6.0)
 ggplot2     * 3.1.1   2019-04-07 [1] CRAN (R 3.6.0)
 ggwordcloud * 0.4.0   2019-04-28 [1] CRAN (R 3.6.0)
 glue          1.3.1   2019-03-12 [1] CRAN (R 3.6.0)
 gtable        0.3.0   2019-03-25 [1] CRAN (R 3.6.0)
 htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.6.0)
 httpuv        1.5.1   2019-04-05 [1] CRAN (R 3.6.0)
 jsonlite      1.6     2018-12-07 [1] CRAN (R 3.6.0)
 labeling      0.3     2014-08-23 [1] CRAN (R 3.6.0)
 later         0.8.0   2019-02-11 [1] CRAN (R 3.6.0)
 lazyeval      0.2.2   2019-03-15 [1] CRAN (R 3.6.0)
 magrittr      1.5     2014-11-22 [1] CRAN (R 3.6.0)
 mime          0.6     2018-10-05 [1] CRAN (R 3.6.0)
 munsell       0.5.0   2018-06-12 [1] CRAN (R 3.6.0)
 pillar        1.4.1   2019-05-28 [1] CRAN (R 3.6.0)
 pkgconfig     2.0.2   2018-08-16 [1] CRAN (R 3.6.0)
 plyr          1.8.4   2016-06-08 [1] CRAN (R 3.6.0)
 png           0.1-7   2013-12-03 [1] CRAN (R 3.6.0)
 promises      1.0.1   2018-04-13 [1] CRAN (R 3.6.0)
 purrr         0.3.2   2019-03-15 [1] CRAN (R 3.6.0)
 R6            2.4.0   2019-02-14 [1] CRAN (R 3.6.0)
 Rcpp          1.0.1   2019-03-17 [1] CRAN (R 3.6.0)
 rlang         0.3.4   2019-04-07 [1] CRAN (R 3.6.0)
 rstudioapi    0.10    2019-03-19 [1] CRAN (R 3.6.0)
 scales        1.0.0   2018-08-09 [1] CRAN (R 3.6.0)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.0)
 shiny       * 1.3.2   2019-04-22 [1] CRAN (R 3.6.0)
 tibble        2.1.1   2019-03-16 [1] CRAN (R 3.6.0)
 tidyselect    0.2.5   2018-10-11 [1] CRAN (R 3.6.0)
 withr         2.1.2   2018-03-15 [1] CRAN (R 3.6.0)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 3.6.0)

[1] /usr/local/lib/R/3.6/site-library
[2] /usr/local/Cellar/r/3.6.0_2/lib/R/library

As a quick aside, I occasionally am getting the following error in an interactive session, outside of Shiny:

Error in mask[pmin(pmax(1, -j + seq_grid_h), gh_pix), pmin(pmax(1, i + : subscript out of bounds

It seems to occur when I have a certain length word, or certain number of words, to be plotted. But, I also do have another linux server with R 3.6 now where I can't reproduce ANY of the errors. So definitely a confusing one. Let me know if I can provide any more information.

lepennec commented 5 years ago

I've made an attempt to fix this out of bounds issue. Can you try the mask_error branch of the devel version:

remotes::install_github("lepennec/ggwordcloud", ref = "mask_error")
erichare commented 5 years ago

Thanks for working on this! Unfortunately I do get the same error using this branch - and I had a colleague test it and she also does - She has the same system configuration as I do. Let me know if there's anything more I can provide to try to help debug it.

lepennec commented 5 years ago

I add another check where I think there could be an issue. Can you try the new version? Thank you!

On Thu, May 30, 2019 at 8:51 PM Eric Hare notifications@github.com wrote:

Thanks for working on this! Unfortunately I do get the same error using this branch - and I had a colleague test it and she also does - She has the same system configuration as I do. Let me know if there's anything more I can provide to try to help debug it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lepennec/ggwordcloud/issues/9?email_source=notifications&email_token=AB4BD2MOW6NB3FY6WA2CH7LPYAO2NA5CNFSM4HQHF3N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWTGAII#issuecomment-497442849, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4BD2ICTSLHPU2ZGTSBVV3PYAO2NANCNFSM4HQHF3NQ .

lepennec commented 5 years ago

Thank you for the info and the error message that should help me a lot!

On Thu, May 30, 2019 at 4:18 PM Eric Hare notifications@github.com wrote:

Sure, here it is:

─ Session info ─────────────────────────────────────────────────────────────────────────

setting value

version R version 3.6.0 (2019-04-26)

os macOS Mojave 10.14.5

system x86_64, darwin18.5.0

ui RStudio

language (EN)

collate en_US.UTF-8

ctype en_US.UTF-8

tz America/Los_Angeles

date 2019-05-30

─ Packages ─────────────────────────────────────────────────────────────────────────────

package * version date lib source

assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)

cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)

colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)

crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)

digest 0.6.19 2019-05-20 [1] CRAN (R 3.6.0)

dplyr 0.8.1 2019-05-14 [1] CRAN (R 3.6.0)

ggplot2 * 3.1.1 2019-04-07 [1] CRAN (R 3.6.0)

ggwordcloud * 0.4.0 2019-04-28 [1] CRAN (R 3.6.0)

glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)

gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)

htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.0)

httpuv 1.5.1 2019-04-05 [1] CRAN (R 3.6.0)

jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0)

labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0)

later 0.8.0 2019-02-11 [1] CRAN (R 3.6.0)

lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0)

magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)

mime 0.6 2018-10-05 [1] CRAN (R 3.6.0)

munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)

pillar 1.4.1 2019-05-28 [1] CRAN (R 3.6.0)

pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.0)

plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.0)

png 0.1-7 2013-12-03 [1] CRAN (R 3.6.0)

promises 1.0.1 2018-04-13 [1] CRAN (R 3.6.0)

purrr 0.3.2 2019-03-15 [1] CRAN (R 3.6.0)

R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0)

Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.6.0)

rlang 0.3.4 2019-04-07 [1] CRAN (R 3.6.0)

rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0)

scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0)

sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)

shiny * 1.3.2 2019-04-22 [1] CRAN (R 3.6.0)

tibble 2.1.1 2019-03-16 [1] CRAN (R 3.6.0)

tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.0)

withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)

xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0)

[1] /usr/local/lib/R/3.6/site-library

[2] /usr/local/Cellar/r/3.6.0_2/lib/R/library

As a quick aside, I occasionally am getting the following error in an interactive session, outside of Shiny:

Error in mask[pmin(pmax(1, -j + seq_grid_h), gh_pix), pmin(pmax(1, i + : subscript out of bounds

It seems to occur when I have a certain length word, or certain number of words, to be plotted. But, I also do have another linux server with R 3.6 now where I can't reproduce ANY of the errors. So definitely a confusing one. Let me know if I can provide any more information.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lepennec/ggwordcloud/issues/9?email_source=notifications&email_token=AB4BD2JGGUO4PGVASZQSWADPX7O35A5CNFSM4HQHF3N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWSOMXI#issuecomment-497346141, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4BD2IIZE4YNAIILVLB6ZLPX7O35ANCNFSM4HQHF3NQ .

erichare commented 5 years ago

Fantastic!! it works for me in the new version!! Tested some other examples and they're all working for me now. Thanks a lot for the work on this!

lepennec commented 5 years ago

Great! I'm going to push the correction...

On Fri, May 31, 2019 at 4:46 PM Eric Hare notifications@github.com wrote:

Fantastic!! it works for me in the new version!! Tested some other examples and they're all working for me now. Thanks a lot for the work on this!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lepennec/ggwordcloud/issues/9?email_source=notifications&email_token=AB4BD2PDXE4KX5HMFXJSWDDPYE24HA5CNFSM4HQHF3N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWVNN4Q#issuecomment-497735410, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4BD2PZ5STP5QU5O7ZTRDDPYE24HANCNFSM4HQHF3NQ .