To write a code block in a .org
file, you can simple type <s
followed by TAB key. Then a skeleton like the following is
automatically inserted:
#+begin_src
#+end_src
All you need to do next is type a single letter R
in the header and
begin typing R code:
#+begin_src R
## Edit Your R Code Here.
x <- rnorm(100)
summary(x)
#+end_src
I recommend you to edit R code in ESS (Emacs Speaks Statistics) mode
by typing "C-c '" (i.e. C-c and single quote) within the code block,
which brings up a separate window with ESS enabled. After editing, you
can type "C-c '" again to return to the main file buffer.
Once you finish writing the code, you can execute them immediately by
pressing C-c C-c
and see the R output being inserted into the
document. Alternatively, you can press C-c C-o
to see the R output
in a separate window.
To generate (export to) HTML document, press C-c C-e b
. Note other
document options are available upon pressing C-c C-e
.