Hi everyone,
first post for me so apologize. This post is very very similar to “Picking joint bandwidth of NaN” when plotting density distribution with ggridges in R. As I could not re-open it and the only answer does not apply to my case, I dared to bring it up.
toplot = structure(list(Year = c("2000", "2000", "2001", "2001", "2002",
"2002", "2003", "2003", "2004", "2004", "2005", "2005", "2006",
"2006", "2007", "2007", "2008", "2008", "2009", "2009", "2010",
"2010", "2011", "2011", "2012", "2012", "2013", "2013", "2014",
"2014", "2015", "2015", "2016", "2016", "2017", "2017", "2018",
"2018", "2019", "2019", "2020", "2020", "2021", "2021"), genes = c("DAO",
"IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2",
"DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO",
"IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2",
"DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO",
"IDH2", "DAO", "IDH2", "DAO", "IDH2", "DAO", "IDH2"), n = c(2L,
0L, 2L, 0L, 2L, 0L, 3L, 0L, 5L, 0L, 5L, 0L, 4L, 0L, 6L, 0L, 2L,
0L, 4L, 0L, 13L, 0L, 7L, 0L, 7L, 0L, 169L, 1L, 182L, 0L, 215L,
56L, 147L, 11L, 165L, 115L, 10L, 62L, 13L, 74L, 14L, 59L, 67L,
44L)), row.names = c(NA, -44L), class = c("tbl_df", "tbl", "data.frame"
))
I would like to produce a plot analogue to any plot present [here]( Gallery of ggridges examples (r-project.org)).
The command I was trying to use is the following:
toplot %>%
mutate(YearFct = fct_rev(as.factor(Year))) %>%
ggplot(aes(y = YearFct)) +
geom_density_ridges(
aes(x = n, fill = paste(YearFct, genes)),
alpha = .8
) +
labs(
x = "No_Patent",
y = "Year"
) +
coord_cartesian(clip = "off") +
theme_ridges(grid = FALSE)
But I got the following error message:
"Picking joint bandwidth of NaN", which I can't understand as I can generate histogram any time I want with same df.
Any pointer for me?
Best
Andrea
Here my session info
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggforce_0.3.3 ggridges_0.5.3 readxl_1.3.1 lubridate_1.8.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.8 purrr_0.3.4 readr_2.1.2
[10] tidyr_1.2.0 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] tidyselect_1.1.1 haven_2.4.1 colorspace_2.0-3 vctrs_0.3.8 generics_0.1.2 utf8_1.2.2 rlang_1.0.2
[8] pillar_1.7.0 glue_1.6.2 withr_2.5.0 DBI_1.1.1 tweenr_1.0.2 dbplyr_2.1.1 RColorBrewer_1.1-2
[15] modelr_0.1.8 lifecycle_1.0.1 plyr_1.8.6 munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_1.0.2
[22] labeling_0.4.2 tzdb_0.1.1 fansi_0.4.2 broom_0.7.12 Rcpp_1.0.7 scales_1.1.1 backports_1.2.1
[29] jsonlite_1.7.2 farver_2.1.0 fs_1.5.2 hms_1.1.1 digest_0.6.27 stringi_1.6.1 polyclip_1.10-0
[36] grid_3.6.1 cli_3.2.0 tools_3.6.1 magrittr_2.0.2 crayon_1.5.0 pkgconfig_2.0.3 ellipsis_0.3.2
[43] MASS_7.3-51.4 xml2_1.3.2 reprex_2.0.1 assertthat_0.2.1 httr_1.4.2 rstudioapi_0.13 R6_2.5.1
[50] compiler_3.6.1