I want to execute R code blocks in
org-mode and export the results to a PDF/html.
Here is an example:
Some text here... #+begin_src R :results output latex library(xtable) x <- rnorm(100) y <- x + rnorm(100) xtable(summary(lm(y ~ x))) #+end_src
I want to export the results (here, the output of
xtable(summary(lm(y ~ x)))), but I can't figure out how to do it. When I export it to LaTeX or html, the text and code is exported nicely, but no table is produced in the output pdf / html file. This is the core problem I need help with. How do I get the results to export, and not just the code?
I have tried several experiments but not sure what settings I need to change.
If I execute the code inline (using
C-c C-c), I am asked to allow for execution, and when allowed a beautiful LaTeX table is generated below the code as expected. Not sure why this is not happening when exporting to LaTeX or html.
I know that code is executing: If I modify the switches as below and then export to LaTeX/html, an output file is produced with appropriate name, but no results are integrated into resultant LaTeX pdf or html file. The syntax coloring is still present.
#+begin_src R :results output latex :session *myR* :dir "." :file r-output.org library(xtable) x <- rnorm(100) y <- x + rnorm(100) xtable(summary(lm(y ~ x))) #+end_src