user3321294
user3321294

Reputation: 329

Output results of cat() in emacs org R source block

I am trying to get the result of a cat() command included in my emacs org file as a result. I am trying the following

#+BEGIN_SRC R :session *R* :exports results :results replace output raw :eval export
 cat(c("1","2","3"))
#+END_SRC

When I evaluate that I see nothing.

When I do this:

#+BEGIN_SRC R :session *R* :exports results :results replace output raw :eval export
 print(c("1","2","3"))
#+END_SRC

And evaluate I get this:

#+RESULTS:
[1] "1" "2" "3"

Which I cannot use.

Background: I would like to print elements of latex tables in R and then include in the export within a tabulate environment. I know there exists functions like xtable() but this is the most flexible approach and works very well for complicated tables. I've done that with cat() in Sweave and it works great.

Thanks!

Upvotes: 3

Views: 182

Answers (1)

user3321294
user3321294

Reputation: 329

This issue was addressed in a similar post here by Eric Schulte:

https://lists.gnu.org/archive/html/emacs-orgmode/2013-03/msg01600.html

Results are not noticed without a newline. However, it is also important to put the newline argument in the printed argument, otherwise the result will include ">" from the next line in R.

So this works:

#+BEGIN_SRC R :session *R* :results output raw
  cat(c("1","2","3","\n"))
#+END_SRC

#+RESULTS:
1 2 3

Upvotes: 3

Related Questions