GuangchuangYu / ggplotify

ggplot everything
https://cran.r-project.org/package=ggplotify/vignettes/ggplotify.html
105 stars 11 forks source link

Doesn't play well with purrr::map() #2

Closed pat-s closed 6 years ago

pat-s commented 6 years ago

Probably due to the required ~ character within as.ggplot2(). It probablys interfers with the ~ operator of map() and hence map() cannot find .x anymore. Leaving it out throws no error but then as.ggplot2() "fails to convert".

plots = map(speclibs, ~ as.ggplot(~ plot(.x)))

Fehler in plot(.x) : Objekt '.x' nicht gefunden

No reprex right now, sorry. But maybe you know where the clash is located. speclibs here is a list containing multiple objects that are correctly plotted by plot().

If it helps, I can provide a reprex later. Thanks for the nice idea of this package!

GuangchuangYu commented 6 years ago
d = list(a=1:10, b=1:10)
## function interface was documented in online vignette
plt = map(d, ~ as.ggplot(function() plot(.x)))
cowplot::plot_grid(plotlist=plt, ncol=2)
pat-s commented 6 years ago

Thanks! Didn't see it in the vignette.