How to evaluate the code in turn in org mode?

I want to be able to execute code line by line in a piece of code that resides in an organization buffer. My goal is to execute the code in turn without having to run all the code inside the piece at the same time (Cc Cc) and without having to switch to a special buffer (Cc '). I use R, but it can be applied to any other language. Is there any way to do this?

Example. Run only the first line in the following code snippet, so that the variable a will get the value 7 in the session.

#+BEGIN_SRC R :session a <- 3 + 4 a <- 5 + 6 #+END_SRC 
+7
emacs org-mode org-babel
source share
2 answers

Not the complete answer, but I would say that if you want to run in turns, it is probably best to do this in a real R session until you figure out what you really want.

If you really want to get the results in several stages, you can split the code into several blocks and they will use one session of the session of the R session

 #+BEGIN_SRC R :session a <- 3 + 4 #+END_SRC #+RESULTS: : 7 #+BEGIN_SRC R :session a <- a + 6 #+END_SRC #+RESULTS: : 13 
+5
source share

In a code block, you can use Cc Cv z to switch to a session with code. You can then evaluate line by line as if you were in a .R file and returned to the .org file with C-'

See the documentation. or Cc Ch in a .org file for quick reference.

+2
source share

All Articles