[TxMt] Re: LaTeX (Sweave)/HTML/Markdown and Rdaemon (R)

Hans-Jörg Bibiko bibiko at eva.mpg.de
Sat Jul 5 22:43:30 UTC 2008


On 05.07.2008, at 23:42, Sean Anderson wrote:

>> ... my idea was to combine LaTeX and Rdaemon. I wrote a new Language
>> for LaTeX called "LaTeX Rdaemon". ...
>>
>> Are there any comments about my approach? What kind of side-effects
>> could be expected?
First of all, this approach won't replace Sweave. Sweaving means that  
the R code will be executed "while" typesetting. The 'LaTeX Rdaemon'  
language approach will execute the R code if you press RETURN,  
meaning the typesetting process won't run any R code. This approach  
'only' simplifies some issues.

Up to now I have the following workflow.

I have a tex document. If I invoke the snippet 'rdenv' a new LaTeX  
environment \begin{Rdaemon} will be included and a new Rdaemon  
session will be started. The Rdaemon start process will look for a  
Rdata image in the same folder as the tex document is saved and if  
there is one it will be loaded (the same for the history).
Then I have a snippet 'rd' which includes that Rdaemon environment  
(that environment is based on verbatimtab).
I can execute some R code. The result will be written into the tex  
document.

> I suppose you'd also have to break out of verbatim to print the  
> figure.

If I plot something like 'plot(1:10)' I see that plot in the quartz  
window. Here I have a command which saves the active R device as PDF  
into the text document folder (without closing the active quartz  
window). If you have the tex document open in a TM project showing  
that folder you will see the new created PDF in the drawer. Then you  
can drag'n'drop that PDF into the the tex document to insert it via  
\begin{figure} etc.
If I save a tex document the current R workspace will also be saved  
via save.image.


> I'm wondering what the best way would be to deal with tabular output?
> Would you want to break out of verbatim and put it in a tabular
> environment or just leave it as is?
This is a good question. My first idea is that I type the name of a  
variable containing that table and then I invoke a command à la  
'Insert as TeX table'. This command will take the variable name and  
will use e.g. xtable::print to insert a TeX table.


>> Would this be useful at all?
>
> Definitely - I'd be keen to experiment with it when you're ready!
Please be patient. There are hundreds of tiny things to ... ;)

--Hans


More information about the textmate mailing list