emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] noweb expansion of LaTeX output from R
@ 2009-11-01 21:45 Thomas S. Dye
  2009-11-01 22:24 ` Dan Davison
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2009-11-01 21:45 UTC (permalink / raw)
  To: emacs-orgmode

Aloha all,

Is it possible to use the noweb syntax to pass LaTeX output from R  
into a latex source block?  I thought this would work, but the noweb  
expansion yields nil.

Please note that this is just a question and not a request for a  
change to org-babel.  In this particular case, the best solution for  
my workflow appears to be sending the table to a file, where I can  
tweak the results more easily and completely than I can using the  
facilities of the xtable package in R.

It does seem like a potentially useful path, though.

The following source and results blocks illustrate the situation, but  
won't run unless you have a whole.adze object in the R session.  If  
need be, I can supply an example that will stand alone.

All the best,
Tom

#+begin_src latex
  Here is the output of the quantile
   function: <<r-weight-quantile()>>.
#+end_src

#+srcname: r-weight-quantile
#+begin_src R :session :noweb :results output
  library(xtable)
  weight <- quantile(whole.adze$weight)
  xtable(as.data.frame(weight))
#+end_src

#+resname: r-weight-quantile
#+begin_example
% latex table generated in R 2.9.2 by xtable 1.5-5 package
% Sun Nov  1 11:17:44 2009
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
   \hline
  & weight \\
   \hline
0\% &   0 \\
   25\% &  22 \\
   50\% &  34 \\
   75\% &  83 \\
   100\% & 2580 \\
    \hline
\end{tabular}
\end{center}
\end{table}
#+end_example

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

* Re: [babel] noweb expansion of LaTeX output from R
  2009-11-01 21:45 [babel] noweb expansion of LaTeX output from R Thomas S. Dye
@ 2009-11-01 22:24 ` Dan Davison
       [not found]   ` <4A5A0920-3560-40A2-BC17-67198796720D@tsdye.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Davison @ 2009-11-01 22:24 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

"Thomas S. Dye" <tsd@tsdye.com> writes:

> Aloha all,
>
> Is it possible to use the noweb syntax to pass LaTeX output from R
> into a latex source block?  I thought this would work, but the noweb
> expansion yields nil.
>
> Please note that this is just a question and not a request for a
> change to org-babel.  In this particular case, the best solution for
> my workflow appears to be sending the table to a file, where I can
> tweak the results more easily and completely than I can using the
> facilities of the xtable package in R.
>
> It does seem like a potentially useful path, though.
>
> The following source and results blocks illustrate the situation, but
> won't run unless you have a whole.adze object in the R session.  If
> need be, I can supply an example that will stand alone.
>
> All the best,
> Tom
>
> #+begin_src latex
>  Here is the output of the quantile
>   function: <<r-weight-quantile()>>.
> #+end_src
>
> #+srcname: r-weight-quantile
> #+begin_src R :session :noweb :results output
>  library(xtable)
>  weight <- quantile(whole.adze$weight)
>  xtable(as.data.frame(weight))
> #+end_src

Hi Tom,

Do you get the behaviour you want if you change that to 
':results output latex'?

Dan


>
> #+resname: r-weight-quantile
> #+begin_example
> % latex table generated in R 2.9.2 by xtable 1.5-5 package
> % Sun Nov  1 11:17:44 2009
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{rr}
>   \hline
>  & weight \\
>   \hline
> 0\% &   0 \\
>   25\% &  22 \\
>   50\% &  34 \\
>   75\% &  83 \\
>   100\% & 2580 \\
>    \hline
> \end{tabular}
> \end{center}
> \end{table}
> #+end_example
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] noweb expansion of LaTeX output from R
       [not found]     ` <87aaz5q0c5.fsf@stats.ox.ac.uk>
@ 2009-11-02  2:59       ` Thomas S. Dye
  2009-11-02  3:36       ` Thomas S. Dye
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas S. Dye @ 2009-11-02  2:59 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode


On Nov 1, 2009, at 1:42 PM, Dan Davison wrote:

> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> On Nov 1, 2009, at 12:24 PM, Dan Davison wrote:
>>
>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>
>>>> Aloha all,
>>>>
>>>> Is it possible to use the noweb syntax to pass LaTeX output from R
>>>> into a latex source block?  I thought this would work, but the  
>>>> noweb
>>>> expansion yields nil.
>>>>
>>>> Please note that this is just a question and not a request for a
>>>> change to org-babel.  In this particular case, the best solution  
>>>> for
>>>> my workflow appears to be sending the table to a file, where I can
>>>> tweak the results more easily and completely than I can using the
>>>> facilities of the xtable package in R.
>>>>
>>>> It does seem like a potentially useful path, though.
>>>>
>>>> The following source and results blocks illustrate the situation,  
>>>> but
>>>> won't run unless you have a whole.adze object in the R session.  If
>>>> need be, I can supply an example that will stand alone.
>>>>
>>>> All the best,
>>>> Tom
>>>>
>>>> #+begin_src latex
>>>> Here is the output of the quantile
>>>> function: <<r-weight-quantile()>>.
>>>> #+end_src
>>>>
>>>> #+srcname: r-weight-quantile
>>>> #+begin_src R :session :noweb :results output
>>>> library(xtable)
>>>> weight <- quantile(whole.adze$weight)
>>>> xtable(as.data.frame(weight))
>>>> #+end_src
>>>
>>> Hi Tom,
>>>
>>> Do you get the behaviour you want if you change that to
>>> ':results output latex'?
>>>
>>> Dan
>>>
>>>
>>
>> Hi Dan,
>>
>> That changes how the table is wrapped in the results block, from #
>> +begin_example to #+BEGIN_LaTeX, but the noweb expansion still yields
>> nil.
>
> Hi Tom,
>
> I'm not sure that I've quite got my head round the various
> latex/babel/tangle/export possibilities that have come up in the  
> recent
> thread! But I feel that this one should have a solution.
>
> So if I do tangle on the following, I get the output below. Is that
> observation relevant to our discussion? What exactly do you mean when
> you say the noweb expansion yields nil? Can you explain the exact  
> steps
> that you're doing?
>
> Dan
>
> -------------------------------------------------------------
> * test R->latex
> #+begin_src latex :tangle td.tex
> Here is the output of the quantile
>  function:
> <<r-weight-quantile()>>.
> #+end_src
>
> #+srcname: r-weight-quantile()
> #+begin_src R :session :noweb :results output latex
> library(xtable)
> xtable(data.frame(cbind(a=1:3,b=4:6)))
> #+end_src
> -------------------------------------------------------------
>
> -----------------------------------------------------------
> %% generated by org-babel-tangle
>
> %% [[git:~/babel/sandbox/r-latex.org::master@{2009-11-01}][block-1]]
> Here is the output of the quantile
>  function:
> % latex table generated in R 2.9.2 by xtable 1.5-5 package
> % Sun Nov  1 18:36:30 2009
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{rrr}
>  \hline
> & a & b \\
>  \hline
> 1 &   1 &   4 \\
>  2 &   2 &   5 \\
>  3 &   3 &   6 \\
>   \hline
> \end{tabular}
> \end{center}
> \end{table}.
> %% block-1 ends here
> -----------------------------------------------------------
>
>>
>> Tom
>>
>>>>
>>>> #+resname: r-weight-quantile
>>>> #+begin_example
>>>> % latex table generated in R 2.9.2 by xtable 1.5-5 package
>>>> % Sun Nov  1 11:17:44 2009
>>>> \begin{table}[ht]
>>>> \begin{center}
>>>> \begin{tabular}{rr}
>>>> \hline
>>>> & weight \\
>>>> \hline
>>>> 0\% &   0 \\
>>>> 25\% &  22 \\
>>>> 50\% &  34 \\
>>>> 75\% &  83 \\
>>>> 100\% & 2580 \\
>>>>  \hline
>>>> \end{tabular}
>>>> \end{center}
>>>> \end{table}
>>>> #+end_example
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Emacs-orgmode mailing list
>>>> Remember: use `Reply All' to send replies to the list.
>>>> Emacs-orgmode@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Hi Dan,

Yes, your example works here, too.

The document I'm working on gives this output:

Here is the output of the quantile
function:
nil.

Now that I know it can work, I'll poke around to see what's going  
wrong.  I'll let you know if I find something  that might have to do  
with org-babel.

Tom

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

* Re: [babel] noweb expansion of LaTeX output from R
       [not found]     ` <87aaz5q0c5.fsf@stats.ox.ac.uk>
  2009-11-02  2:59       ` Thomas S. Dye
@ 2009-11-02  3:36       ` Thomas S. Dye
  2009-11-02  6:08         ` Dan Davison
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2009-11-02  3:36 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

On Nov 1, 2009, at 1:42 PM, Dan Davison wrote:

> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> On Nov 1, 2009, at 12:24 PM, Dan Davison wrote:
>>
>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>
>>>> Aloha all,
>>>>
>>>> Is it possible to use the noweb syntax to pass LaTeX output from R
>>>> into a latex source block?  I thought this would work, but the  
>>>> noweb
>>>> expansion yields nil.
>>>>
>>>> Please note that this is just a question and not a request for a
>>>> change to org-babel.  In this particular case, the best solution  
>>>> for
>>>> my workflow appears to be sending the table to a file, where I can
>>>> tweak the results more easily and completely than I can using the
>>>> facilities of the xtable package in R.
>>>>
>>>> It does seem like a potentially useful path, though.
>>>>
>>>> The following source and results blocks illustrate the situation,  
>>>> but
>>>> won't run unless you have a whole.adze object in the R session.  If
>>>> need be, I can supply an example that will stand alone.
>>>>
>>>> All the best,
>>>> Tom
>>>>
>>>> #+begin_src latex
>>>> Here is the output of the quantile
>>>> function: <<r-weight-quantile()>>.
>>>> #+end_src
>>>>
>>>> #+srcname: r-weight-quantile
>>>> #+begin_src R :session :noweb :results output
>>>> library(xtable)
>>>> weight <- quantile(whole.adze$weight)
>>>> xtable(as.data.frame(weight))
>>>> #+end_src
>>>
>>> Hi Tom,
>>>
>>> Do you get the behaviour you want if you change that to
>>> ':results output latex'?
>>>
>>> Dan
>>>
>>>
>>
>> Hi Dan,
>>
>> That changes how the table is wrapped in the results block, from #
>> +begin_example to #+BEGIN_LaTeX, but the noweb expansion still yields
>> nil.
>
> Hi Tom,
>
> I'm not sure that I've quite got my head round the various
> latex/babel/tangle/export possibilities that have come up in the  
> recent
> thread! But I feel that this one should have a solution.
>
> So if I do tangle on the following, I get the output below. Is that
> observation relevant to our discussion? What exactly do you mean when
> you say the noweb expansion yields nil? Can you explain the exact  
> steps
> that you're doing?
>
> Dan
>
> -------------------------------------------------------------
> * test R->latex
> #+begin_src latex :tangle td.tex
> Here is the output of the quantile
>  function:
> <<r-weight-quantile()>>.
> #+end_src
>
> #+srcname: r-weight-quantile()
> #+begin_src R :session :noweb :results output latex
> library(xtable)
> xtable(data.frame(cbind(a=1:3,b=4:6)))
> #+end_src
> -------------------------------------------------------------
>
> -----------------------------------------------------------
> %% generated by org-babel-tangle
>
> %% [[git:~/babel/sandbox/r-latex.org::master@{2009-11-01}][block-1]]
> Here is the output of the quantile
>  function:
> % latex table generated in R 2.9.2 by xtable 1.5-5 package
> % Sun Nov  1 18:36:30 2009
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{rrr}
>  \hline
> & a & b \\
>  \hline
> 1 &   1 &   4 \\
>  2 &   2 &   5 \\
>  3 &   3 &   6 \\
>   \hline
> \end{tabular}
> \end{center}
> \end{table}.
> %% block-1 ends here
> -----------------------------------------------------------
>
>>
>> Tom
>>
>>>>
>>>> #+resname: r-weight-quantile
>>>> #+begin_example
>>>> % latex table generated in R 2.9.2 by xtable 1.5-5 package
>>>> % Sun Nov  1 11:17:44 2009
>>>> \begin{table}[ht]
>>>> \begin{center}
>>>> \begin{tabular}{rr}
>>>> \hline
>>>> & weight \\
>>>> \hline
>>>> 0\% &   0 \\
>>>> 25\% &  22 \\
>>>> 50\% &  34 \\
>>>> 75\% &  83 \\
>>>> 100\% & 2580 \\
>>>>  \hline
>>>> \end{tabular}
>>>> \end{center}
>>>> \end{table}
>>>> #+end_example
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Emacs-orgmode mailing list
>>>> Remember: use `Reply All' to send replies to the list.
>>>> Emacs-orgmode@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Hi Dan,

This org file reproduces the results I'm seeing.

* test R->latex

#+begin_src latex :tangle td2.tex
Here is the inner block:
<<inner-block>>
#+end_src

#+srcname: inner-block
#+begin_src latex
Here is the output of the quantile
  function:
<<r-weight-quantile()>>.
#+end_src

#+srcname: r-weight-quantile
#+begin_src R :session :noweb :results output latex
library(xtable)
xtable(data.frame(cbind(a=1:3,b=4:6)))
#+end_src


% generated by org-babel-tangle

% [[file:~/Public/projects/903_adzes/org-babel/test-noweb.org::*test 
%20R%20latex][block-1]]
Here is the inner block:

Here is the output of the quantile
  function:
nil.
% block-1 ends here

Tom

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

* Re: [babel] noweb expansion of LaTeX output from R
  2009-11-02  3:36       ` Thomas S. Dye
@ 2009-11-02  6:08         ` Dan Davison
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Davison @ 2009-11-02  6:08 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

"Thomas S. Dye" <tsd@tsdye.com> writes:

> On Nov 1, 2009, at 1:42 PM, Dan Davison wrote:
>
>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>
>>> On Nov 1, 2009, at 12:24 PM, Dan Davison wrote:
>>>
>>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>>
>>>>> Aloha all,
>>>>>
>>>>> Is it possible to use the noweb syntax to pass LaTeX output from R
>>>>> into a latex source block?  I thought this would work, but the
>>>>> noweb
>>>>> expansion yields nil.
<...>
>
> Hi Dan,
>
> This org file reproduces the results I'm seeing.

Hi Tom,

Thanks, I've fixed that, change will be available soon. In the meantime,
I believe that the example does work OK as long as the results of the
r-weight-quantile block are *not* in the org buffer.

Dan

>
> * test R->latex
>
> #+begin_src latex :tangle td2.tex
> Here is the inner block:
> <<inner-block>>
> #+end_src
>
> #+srcname: inner-block
> #+begin_src latex
> Here is the output of the quantile
>  function:
> <<r-weight-quantile()>>.
> #+end_src
>
> #+srcname: r-weight-quantile
> #+begin_src R :session :noweb :results output latex
> library(xtable)
> xtable(data.frame(cbind(a=1:3,b=4:6)))
> #+end_src
>
>
> % generated by org-babel-tangle
>
> % [[file:~/Public/projects/903_adzes/org-babel/test-noweb.org::*test
> %20R%20latex][block-1]]
> Here is the inner block:
>
> Here is the output of the quantile
>  function:
> nil.
> % block-1 ends here
>
> Tom
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2009-11-02  6:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-01 21:45 [babel] noweb expansion of LaTeX output from R Thomas S. Dye
2009-11-01 22:24 ` Dan Davison
     [not found]   ` <4A5A0920-3560-40A2-BC17-67198796720D@tsdye.com>
     [not found]     ` <87aaz5q0c5.fsf@stats.ox.ac.uk>
2009-11-02  2:59       ` Thomas S. Dye
2009-11-02  3:36       ` Thomas S. Dye
2009-11-02  6:08         ` Dan Davison

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).