Hi,
here comes a suggestion for all R users. I wrote a tiny R daemon bundle in order to run R 'inside' of TM. There is no need to start RGUI etc. I found a naive way to do it and it turns out, at least for me, it's quite useful. So my question is whether this approach is also useful for others. If yes, I/we can elaborte this bundle.
Demo Movie (4.3MB) http://www.bibiko.de/Rsession.mov
Up to now you can do the following:
-install this bundle R daemon -open new document, set the language to R or R console, type 'start' and press TAB -R daemon will be installed into $HOME/Rdaemon (please check the directory if you don't use it!) -after some seconds you can type any command into that window and press 'NUMPAD-ENTER' -the result will be inserted into the current document -if you want to execute a selection the output will be written into the file r_res (useful if you write a script) -errors/warnings will be output as tooltip (but not every error, then you have to check 'geterrmessage()'!) -there is a progress bar showing the progress of R's calculation
-the entire session you can find in r_out (the nice side-effect is that even if the R daemon, or TM, or the Mac crashes you have at least r_out to reconstruct the last session) -the R daemon listens at the named pipe r_in -errors/warnings are written to r_err
-if you know that the command will take some minutes you can execute this command in the background (SHIFT+NUMPAD-ENTER); the result will be written into r_res; by doing so you can send a task to R while writing further stuff in TM (I used sink() for that)
-R daemon comes with its own persistant history list (i.e. if you quit the R daemon and you start it again you also have all commands from the last session (OPT+ARROWUP/DOWN CTRL+OPT+ARROWUP for a list [last command comes first]))
-I rewrote the help for the current word as an HTML page using frames
-Autocomplete and command template now works case-sensitive meaning if you look for 'mat' you won't get 'Math.'. Furthermore it also works for functions defined in the current session!
-I included an example TM project Rsession ($HOME/Rdaemon).
-note 1: plot R runs as normal session in a hidden Terminal. Thus one has to use X11 for plotting into the null device. If such a device is open and you quit X11 the R daemon will quit immediately!! I cannot catch this yet.
CTRL+NUMPAD-ENTER can show the current plot as PDF. I set the the pdf file to ~/Rdaemon/plots/Rplot.pdf
-note 2: quit You can type 'q()', delete the prompt and answer the question, or type kill TAB to kill it.
-known pitfall 1: readline In principal readline("prompt") works, but if 'prompt' is prompted, you have to delete it or press ENTER to insert a value. Otherwise R will get the entire line a input (I work on it)
-known pitfall 2: synchronisation One tricky point is the synchronisation of the output. I went the way to look for R's CPU coverage. If this is zero I assume that R's ready. One can test this if you execute 'c(1:200000)'. If you see the last line mentioning you reached the max line etc. everything is OK, if not one has to fine-tune it. It's done via a tiny sleep command.
As I already mentioned this is written very fast!! Esp. the daemon which is written in Ruby needs some help from Ruby experts ;)
With R daemon one has the full control meaning you can do thousand of nifty things ;)
Any comments?
Cheers,
--Hans
Hi,
some additions.
-If you have installed CarbonEL, you also can plot to quartz() without X11.
-tcltk stuff also works (with X11) BUT there is a problem: If I quit my tcltk session via tkdestroy everything is fine BUT R's CPU coverage is then always around 1%??? I don't know why. Even if I start R in a normal Terminal - the same result. Thus one should modify the break statement inside of the execute script.
If one changes this to let's say break if CPU<2% one would also speed up the entire script enormously! But then one has troubles for very large outputs.
Anyway, I'm using this bundle for my daily work and it turns out it works pretty good ;)
--Hans
Hi Hans,
Nice idea! Your screencast on this looks really interesting, so I'll give it a go over the next few days and let you know how I get on.
Cheers, Jon
On 06/12/2007, Hans-Joerg Bibiko bibiko@eva.mpg.de wrote:
Hi,
some additions.
-If you have installed CarbonEL, you also can plot to quartz() without X11.
-tcltk stuff also works (with X11) BUT there is a problem: If I quit my tcltk session via tkdestroy everything is fine BUT R's CPU coverage is then always around 1%??? I don't know why. Even if I start R in a normal Terminal - the same result. Thus one should modify the break statement inside of the execute script.
If one changes this to let's say break if CPU<2% one would also speed up the entire script enormously! But then one has troubles for very large outputs.
Anyway, I'm using this bundle for my daily work and it turns out it works pretty good ;)
--Hans
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 09.12.2007, at 15:22, Jon Clayden wrote:
Nice idea! Your screencast on this looks really interesting, so I'll give it a go over the next few days and let you know how I get on.
Be a bit patient. I'm just fine-tuning it a bit, and I'm just writing a GUI around it. Only with the built-in functionality of TextMate! Here a small screenshot:
It's amazing to see what is possible with TM ;) And everybody is able to change the entire GUI quite easily; it's only a bit HTML/ JavaScript ;)
If one makes usage of TMTOOLS, well, then the possibilities are open- ended.
Cheers,
Hans
Hans,
Thanks... This looks impressive... I will take a look at it & see how this would help compared to the my current work flow using the 'usual' R bundle which has served very well... I also do alot of sweaving BTW..
Does installing the daemon "break" the other R bundles? Will the other R bundles be the active ones until you type 'start' & TAB..? How about after?
I want to help in testing & critiquing the daemon, but need to be able to continue working with the current R bundle in the meantime..
thanks for all your efforts & for sharing....
danstan
On Dec 6, 2007, at 5:38 AM, Hans-Jörg Bibiko wrote:
Hi,
here comes a suggestion for all R users. I wrote a tiny R daemon bundle in order to run R 'inside' of TM. There is no need to start RGUI etc. I found a naive way to do it and it turns out, at least for me, it's quite useful. So my question is whether this approach is also useful for others. If yes, I/we can elaborte this bundle.
Demo Movie (4.3MB) http://www.bibiko.de/Rsession.mov
Up to now you can do the following:
-install this bundle R daemon -open new document, set the language to R or R console, type 'start' and press TAB -R daemon will be installed into $HOME/Rdaemon (please check the directory if you don't use it!) -after some seconds you can type any command into that window and press 'NUMPAD-ENTER' -the result will be inserted into the current document -if you want to execute a selection the output will be written into the file r_res (useful if you write a script) -errors/warnings will be output as tooltip (but not every error, then you have to check 'geterrmessage()'!) -there is a progress bar showing the progress of R's calculation
-the entire session you can find in r_out (the nice side-effect is that even if the R daemon, or TM, or the Mac crashes you have at least r_out to reconstruct the last session) -the R daemon listens at the named pipe r_in -errors/warnings are written to r_err
-if you know that the command will take some minutes you can execute this command in the background (SHIFT+NUMPAD-ENTER); the result will be written into r_res; by doing so you can send a task to R while writing further stuff in TM (I used sink() for that)
-R daemon comes with its own persistant history list (i.e. if you quit the R daemon and you start it again you also have all commands from the last session (OPT+ARROWUP/DOWN CTRL+OPT+ARROWUP for a list [last command comes first]))
-I rewrote the help for the current word as an HTML page using frames
-Autocomplete and command template now works case-sensitive meaning if you look for 'mat' you won't get 'Math.'. Furthermore it also works for functions defined in the current session!
-I included an example TM project Rsession ($HOME/Rdaemon).
-note 1: plot R runs as normal session in a hidden Terminal. Thus one has to use X11 for plotting into the null device. If such a device is open and you quit X11 the R daemon will quit immediately!! I cannot catch this yet.
CTRL+NUMPAD-ENTER can show the current plot as PDF. I set the the pdf file to ~/Rdaemon/plots/Rplot.pdf
-note 2: quit You can type 'q()', delete the prompt and answer the question, or type kill TAB to kill it.
-known pitfall 1: readline In principal readline("prompt") works, but if 'prompt' is prompted, you have to delete it or press ENTER to insert a value. Otherwise R will get the entire line a input (I work on it)
-known pitfall 2: synchronisation One tricky point is the synchronisation of the output. I went the way to look for R's CPU coverage. If this is zero I assume that R's ready. One can test this if you execute 'c(1:200000)'. If you see the last line mentioning you reached the max line etc. everything is OK, if not one has to fine-tune it. It's done via a tiny sleep command.
As I already mentioned this is written very fast!! Esp. the daemon which is written in Ruby needs some help from Ruby experts ;)
With R daemon one has the full control meaning you can do thousand of nifty things ;)
Any comments?
Cheers,
--Hans<R daemon.tmbundle.zip> ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 10 Dec 2007, at 00:06, xolela@mac.com wrote:
Thanks... This looks impressive... I will take a look at it & see how this would help compared to the my current work flow using the 'usual' R bundle which has served very well... I also do alot of sweaving BTW..
Does installing the daemon "break" the other R bundles? Will the other R bundles be the active ones until you type 'start' & TAB..? How about after?
Actually no. The only thing is that the R daemon shares some key combinations. But this should be solvable (maybe via different languages). The R daemon runs in its own environment, meaning one can run R from the Terminal or as R.app without interfering.
I want to help in testing & critiquing the daemon, but need to be able to continue working with the current R bundle in the meantime..
I would be appreciated ;)
but need to be able to continue working with the current R bundle in the meantime..
this shouldn't be the problem
--Hans