1

I have a table in org-mode that I want to pass into an R source block and then plot from it. When I write everything in org-mode and execute it, I get the results that I expect.

However, when I enter the ESS editing mode/org-edit-src-code by toggling C-c ' inside the source block, the variable is not used. This is important for complicated scripts where I have to test multiple things and feed multiple variables/tables into the source block.

Here is an example:

#+name: test-table
| Cell | Value |
|------+-------|
|    1 |    10 |
|    2 |    20 |
|    3 |    60 |
|    4 |    80 |
|    5 |   100 |

#+name: test-table-plot   
#+BEGIN_SRC R :var test=test-table :results output graphics :exports results :file-ext png
plot(test)
#+END_SRC

If I run this source block, I get the plot I expect. If I go into the org-edit-src-code with C-c ' the table "test" does not exist.

Is this meant to be like this? Is there a way to pass the variable to org-edit-src-code?

1 Answer 1

1

Org-babel expands the src block before sending the contents to R. With org-babel-expand-src-block (C-c C-v v) you're in the same edit buffer but the code is "expanded".

1
  • Perfect. I just tested it on a more complex example and it worked! Thank you :)
    – Cumol
    Commented Aug 11, 2017 at 13:38

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.