Getting ggvis::export_png() working

主宰稳场 提交于 2019-12-01 04:36:57

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/*
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!