emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-mode R using xtable produces strange output
@ 2018-03-19 23:44 Brian Shine
  2018-03-20 16:47 ` Berry, Charles
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Shine @ 2018-03-19 23:44 UTC (permalink / raw)
  To: Liste-emacs-orgmode@gnu.org; +Cc: Brian Shine

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

I am using xtable to produce summary tables of linear models, specifying the output as latex.  If I just run the code in R, I get the correct output.  However, the latex output in the org document contains a lot of “|”s.  I think this is because the header of the table contains some code to make “p > |t|”, where the vertical lines are to indicate “absolute value of t”.  My guess is that when the output is written to the results section, org interprets the “|” signs as an org-table and tries to be helpful by adding more of them to make up the correct number of columns. If I switch off the latex output, and write the xtable to a small .tex file, using xtable.print and then include the file after the code block, the table appears correctly.
I’m using emacs 25.2.

Here’s an example:


Best wishes,
Brian



[-- Attachment #2: xtableeg.org --]
[-- Type: application/octet-stream, Size: 1409 bytes --]

#+BEGIN_SRC R :session :exports results :results latex

  library(xtable)

  examp <- data.frame(x = 1:10, y = 10:1)

  print.xtable(xtable(summary(glm(y ~ x, data = examp))))

#+END_SRC

#+RESULTS:
#+BEGIN_EXPORT latex
| % latex table generated in R 3.4.4 by xtable 1.8-2 package        |     |       |
| % Mon Mar 19 23:41:04 2018                                        |     |       |
| \begin{table}[ht]                                                 |     |       |
| \centering                                                        |     |       |
| \begin{tabular}{rrrrr}                                            |     |       |
| \hline                                                            |     |       |
| & Estimate & Std. Error & t value & Pr($>$$                       | $t$ | $) \\ |
| \hline                                                            |     |       |
| (Intercept) & 11.0000 & 0.0000 & 10932581685367508.00 & 0.0000 \\ |     |       |
| x & -1.0000 & 0.0000 & -6166807764706701.00 & 0.0000 \\           |     |       |
| \hline                                                            |     |       |
| \end{tabular}                                                     |     |       |
| \end{table}                                                       |     |       |
|                                                                   |     |       |
#+END_EXPORT

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: org-mode R using xtable produces strange output
  2018-03-19 23:44 org-mode R using xtable produces strange output Brian Shine
@ 2018-03-20 16:47 ` Berry, Charles
  2018-03-20 22:40   ` Brian Shine
  0 siblings, 1 reply; 3+ messages in thread
From: Berry, Charles @ 2018-03-20 16:47 UTC (permalink / raw)
  To: Brian Shine; +Cc: Liste-emacs-orgmode@gnu.org



> On Mar 19, 2018, at 4:44 PM, Brian Shine <brianshine@mac.com> wrote:
> 
> I am using xtable to produce summary tables of linear models, specifying the output as latex.  If I just run the code in R, I get the correct output.  However, the latex output in the org document contains a lot of “|”s.  I think this is because the header of the table contains some code to make “p > |t|”, where the vertical lines are to indicate “absolute value of t”.  My guess is that when the output is written to the results section, org interprets the “|” signs as an org-table and tries to be helpful by adding more of them to make up the correct number of columns. 


See

	(info "(org) results")

and note the difference between `:results output' and `:results value' (the default).

Since you want the printed version of the R object, you should use 

	`:results output latex'

to pass the printed output to the org #+Results or 

	`:results raw :wrap export latex'

to pass the unadorned value.  In your use case they seem to produce the same #+Results.

HTH,

Chuck

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: org-mode R using xtable produces strange output
  2018-03-20 16:47 ` Berry, Charles
@ 2018-03-20 22:40   ` Brian Shine
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Shine @ 2018-03-20 22:40 UTC (permalink / raw)
  To: Berry, Charles; +Cc: Liste-emacs-orgmode@gnu.org, Brian Shine

Brilliant!  Thank you so much.

Best wishes,
Brian


> On 20 Mar 2018, at 16:47, Berry, Charles <ccberry@ucsd.edu> wrote:
> 
> 
> 
>> On Mar 19, 2018, at 4:44 PM, Brian Shine <brianshine@mac.com> wrote:
>> 
>> I am using xtable to produce summary tables of linear models, specifying the output as latex.  If I just run the code in R, I get the correct output.  However, the latex output in the org document contains a lot of “|”s.  I think this is because the header of the table contains some code to make “p > |t|”, where the vertical lines are to indicate “absolute value of t”.  My guess is that when the output is written to the results section, org interprets the “|” signs as an org-table and tries to be helpful by adding more of them to make up the correct number of columns. 
> 
> 
> See
> 
> 	(info "(org) results")
> 
> and note the difference between `:results output' and `:results value' (the default).
> 
> Since you want the printed version of the R object, you should use 
> 
> 	`:results output latex'
> 
> to pass the printed output to the org #+Results or 
> 
> 	`:results raw :wrap export latex'
> 
> to pass the unadorned value.  In your use case they seem to produce the same #+Results.
> 
> HTH,
> 
> Chuck

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-20 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-19 23:44 org-mode R using xtable produces strange output Brian Shine
2018-03-20 16:47 ` Berry, Charles
2018-03-20 22:40   ` Brian Shine

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).