Skip to main content
3 of 5
formatting
Emacs User
  • 5.7k
  • 19
  • 48

I tried to follow your example, both using the :PROPERTIES: drawer like your mysql example and with (same) named code-blocks. Neither is working to call an R variable in the second code-block.

#+TITLE:TEST
#+AUTHOR:Benyomin
#+STARTUP: inlineimages

* try a real session. Name both code-blocks the same.
#+name: section1
#+begin_src R :results output :session

# name the list_var "why"
print("Generate ten numbers")
why <- seq(1,10)
why
print("Then randomize them and print those.")
# make it a bit random
zee <- why * runif(1, .1, 2.3)
zee   # give a simple text output
#plot(zee)  # plot zee  ooops,  save that for the next code block
#+end_src 

#+RESULTS:
: [1] "Generate ten numbers"
:  [1]  1  2  3  4  5  6  7  8  9 10
: [1] "Then randomize them and print those."
:  [1]  1.209789  2.419579  3.629368  4.839157  6.048946  7.258736  8.468525
:  [8]  9.678314 10.888103 12.097893

** but will this part work?

Here is a long description of 3 paragraphs stuck in the middle of some code. Can the second piece of code refer to things done in the earlier code block? That's something very important for me.

#+name: section1
#+BEGIN_SRC R :file example2.png :results graphics
print("Plot a variable created in a different code block.")
plot(zee)
print("result is white box with object 'zee' not found")
#+END_SRC