[TxMt] New R bundles available + An idea

Hans-Joerg Bibiko bibiko at eva.mpg.de
Mon Mar 17 15:11:08 UTC 2008


ONLY A FAST THOUGHT IDEA!

SWeaving is a very nice workaround. But sometimes you only want to  
draw some simple things like

plot(x <- sort(rnorm(47)), type = "s", ylab="foo")
points(x, cex = 1, col = "dark red")

or whatever.

Within a latex doc one could write it like this:

% plot(x <- sort(rnorm(47)), type = "s", ylab="foo")
% points(x, cex = 1, col = "dark red")

to comment out the R code and to be able to redo it if needed.

Then select this R code, invoke R > Run Selection/Document in R (it  
should be rewritten to ignore the leading "% " if it's invoked out of  
a latex doc). You will get the plot shown as PDF inside of the Rmate  
window. Then simply drag and drop that plot to the latex doc after  
the R code which produced it.
The latex bundle drag&drop (DD) command "Include Image" should be  
fine-tuned in such a way that if TM_DROPPED_FILEPATH begins with  
"file:///tmp/TM_R/" it popups a dialog to enter a new name for this  
plot. The variable "filename" of the DD command will be reset to the  
new file name. The actual PDF stored in tmp/TM_R will be copied into  
the folder of the latex doc with the new name, and after it the DD  
command works as usual.

Of course, one could pass the name or path of the plot in beforehand  
like:
%% name="figure1"
% plot(x <- sort(rnorm(47)), type = "s", ylab="foo")
% points(x, cex = 1, col = "dark red")

I do not know if this is worth to implement?
[BTW Please note, I don't want to reinvent SWeave ;)]
Any Comments?

Cheers,

--Hans



More information about the textmate mailing list