[TxMt] problem with R interaction [was math bundle feature request]

Charilaos Skiadas skiadas at hanover.edu
Fri Dec 8 22:03:26 UTC 2006


On Dec 8, 2006, at 3:49 PM, Hans-Joerg Bibiko wrote:
> But I looked at the R-Bundle and I wrote a command (in bash) which  
> executes R directly in script mode à la
>
> R --no-save --silent <<< "$TASK" 2>/dev/null
>
> There is no need to use Applescript or running R.app in beforehand  
> to calculate some tiny things, pasting results to and fro...
>
> This command takes the Selection or Line, executes this by using R,  
> and replaces the Selection with the result without leading '[]'. If  
> an error occurs or 'Inf' or 'NaN' is returned it shows a tooltip.
>
> Please note, this is only a fast written script as a basis for  
> discussions, and can modified in any direction. I tried it out and  
> things like
> 1/1e-1, 100^2, mean(c(1:20)), print("HALLO") worked fine.
> Things like 'matrix(c(1:20),nrow=4) also work but without leading  
> row numbers of course. Warnings and error messages are suppressed.

> Maybe this could be an approach to solve this problem with R.
>
This was my first approach to this too. The problem is that this is  
relatively slow, because it has to load R each time, and that does  
take up time. The interpreter sounds like a better idea, but it  
doesn't work out of the box. (well, I guess we don't even know if we  
can make it work at all yet ;) ).
There is an approach that is relatively doable but had technical  
problems. We can start an R process in the background, and  
communicate to it via named pipes, which you can think of if you like  
as files on the hard drive that TM would write to and R would read  
from. This would be reasonably fast. The problem we are encountering,  
so to speak, is that this would mean a shared R environment for all  
your R work. So imagine you are working on three different R  
projects, on different R windows. They might be defining conflicting  
varialbes and messing up each other's computations, if they are sent  
to the same R process. So this adds a considerable amount of details  
that need to be overcome.

> An other approach could be the rinterp
>
> http://wiki.r-project.org/rwiki/doku.php?id=developers:rinterp
>
> I use this on my Linux server and it works perfectly. With the help  
> of this you can write raw R source code within a command in TM and  
> executes this like perl, ruby, python etc.
>
> The only thing I don't know whether it is possible to compile this  
> on a Mac. I can remember that you have to compile R with shared  
> libraries in beforehand, but I'm not quite sure about that.
>
> -Hans

Haris





More information about the textmate mailing list