I'd like to find a way to evaluate my R code remotely, but insert images into my local org file.

I use R code blocks in my org files and insert images into the org file with something like this:

#+begin_src R :exports results :results graphics :file test.png

When ESS prompts me with:

ESS (*R*, R (default)) starting data directory?

I enter a remote location, e.g. /ssh:server:~/project/

The figure is then created in the remote directory and a link is inserted in the #+RESULTS, however this link "cannot determine image type". Basically the image isn't local and so isn't viewable. If I copy the image to the local directory, the link works and I see the image as if I had evaluated the code chunk locally.

I've also tried adding a :dir header argument and the full path to the image, like this:

#+begin_src R :exports results :results graphics :dir erker@krusty:~/ :file /tmp/test2.png

Can I specify somehow in the header arguments to write the file to a local directory so that it is inserted in the org file?

  • I don't get the ESS prompt you mention; instead the way I know to specify remote execution is to supply a :dir header argument that specifies a remote directory. To save the file locally, try specifying a full local pathname for the :file header argument, so something like ':file /tmp/test.png :dir user@server:/project`. All this is untested however, so I'm not sure it will work. – NickD Feb 24 '17 at 5:08
  • Thanks for the suggestion. I tried the full path and it didn't work either. My thinking now is the issue is more to do with R than with org. I need to figure out how to get a remote R session to write to a local file. – Tedward Feb 24 '17 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.