Getting ggvis::export_png() working

后端 未结 1 2004
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 17:51

Goal

Export a ggvis figure as a PNG file (for inclusion in an .Rmd document).

Problem

I know essentially nothing about Node.js, othe

相关标签:
1条回答
  • 2021-01-12 18:46

    There are a few moving targets which need to be pinned down to get ggvis and the export_ tools working.

    Vega 2+ series releases don't accept the json ggvis generates for the vg2XXX commands, which are used for the exporting, so vega needs to be pinned to v1.5.4 which is the last of the v1 series. The problem with that is nodejs 4.x+ wont install vega@1.5.4 and requires the newer vega versions. Thankfully we can use node version manager (nvm) to pin the node version to node 0.12.7 which allows us to install vega.

    What a PITA, yes? If you do this within a scriptable container (like with a Rocker container) environment it is much easier. I've been using a Rstudio setup that includes this dockerfile containing these pertinent lines...

    RUN \
    # Vega 2 doesn't accept the json ggvis generates when trying to use vg2XXX
    # commands so vega needs to be pinned. nodejs 4.x wont install vega@1.5.4...
    mkdir .local/lib/nvm; \
    ln -s .local/lib/nvm .nvm; \
    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash; \
    . .nvm/nvm.sh; \
    sudo bash -c ". .nvm/nvm.sh;\
     nvm install 0.12.7;\
     nvm alias default 0.12.7;\
     npm install --silent vega@1.5.4;"; \
    ln -s -t ~/.local/bin ~/node_modules/vega/bin/*
    
    0 讨论(0)
提交回复
热议问题