I am trying to somehow use a local variable in org-mode for when I write my R code. So essentially in have this chunk that I want to automatically manage for each file.

#+BEGIN_SRC R :file /Users/ashok/Documents/plots/wtdup.png

in the chunk above I want to be able to replace the value for the :file with a path to the plots folder that could change. So I tried to use the local variable approach as below

## Local Variables:
## mode: org
## plotfolder: "/Users/DataAnalysis/FinalAnalysisMay2016/plots"
## End:

and then replace the :file parameter with

#+BEGIN_SRC R :file (eval 'plotfolder)"/truseq_comp_logcpm_pairwise_wtdup.png"
  pairs.panels(tmpDat.cpm.log[,c(5,7,8,21:23)], )

Now when I evaluate the chunk ( after reverting my buffer to make the local variable active), the result includes only the value of the plotfolder variable and not the concatenated version as I wanted. in this case my results would show up as


but what i really want is


If anyone has any suggestions as to how I can go about this it would be great, since then I can move the same files between machines when I am working on cleaning up the results.

  • 1
    (concat plotfolder "/truseq_comp_logcpm_pairwise_wtdup.png") ?
    – phils
    Jun 8, 2016 at 23:08
  • I tried that and I get the "symbols function definition is void" error Jun 9, 2016 at 14:38

1 Answer 1


Got it i used the emacs concat function as suggested by @phils above but i had to figure out how it was evaluated. Here is the solution

#+BEGIN_SRC R :file (concat (eval plot folder) "/truseq_comp_logcpm_pairwise_wtdup.png")
  pairs.panels(tmpDat.cpm.log[,c(5,7,8,21:23)], )

To summarize. Say you wanted to specify a variable text in org-mode then in the example above add plotfolder to the local variables as mentioned and then use concat as above to add say prefixes or suffixes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.