1

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
  pairs.panels(tmpDat.cpm.log[,c(1:4,17:20)],)
#+END_SRC

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 VARS
## 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)], )
#+END_SRC

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

#+RESULTS
/Users/DataAnalysis/FinalAnalysisMay2016/plots

but what i really want is

#+RESULTS
/Users/DataAnalysis/FinalAnalysisMay2016/plots/truseq_comp_logcpm_pairwise_wtdup.png

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 '16 at 23:08
  • I tried that and I get the "symbols function definition is void" error – ashokragavendran Jun 9 '16 at 14:38
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)], )
#+END_SRC

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, privacy policy and cookie policy

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