On Mon, 14 Oct 2013 08:14:20 -0700 (PDT)
Fidel N <[email protected]> wrote:

> Thank you Terry. I find your answer extremely valuable.
> 
> I would like to share a thought on this. What I really wanted to know is 
> how to "connect" R with Leo.
> After reading your answer I could realize how deep your answer is, and how 
> on the surface my knowledege about that is... so I went find some R samples 
> and realize it will just be a matter of installing R, dropping an R script 
> into Leo,then run it, and it will run.

Well, not really.  For Leo / R code execution integration I'm using the
leoscreen plugin, which leverages the gnu screen "terminal
multiplexer", http://www.gnu.org/software/screen/manual/
so the solution only applies to unixish OSes.  Specifically screen lets
other programs push and pull text into and out of a terminal running at
the same time, and that's what I use to send code from Leo to R.

There's a python / R bridge which I imagine could be imported in Leo
and used for an OS neutral approach, I just used leoscreen because it's
a generic solution for Leo / terminal-based-app interaction.  In fact I
not infrequently accidentally have Leo send SQL code to a bash shell,
which can make a mess.

> But I think it would be great if Leo included, as a branch of the guide for 
> new users, in which it would say hello world in several languages, showing 
> how you can build a csv file in python, analyze it with R, then output the 
> result as a website or restructured text, all of them within one outline.

Given the above about leoscreen, I'm not sure how many languages this
would apply to.

The coffeescript I'm not executing from Leo at all, just editing,
although in unix* leoscreen would work with that too.

Edward mentioned something recently about using Leo to execute Java
scripts etc. - I'm not sure about the persistence of the execution
context in those cases, usually something you'd want with R.

Cheers -Terry

> Not only you are showing in a brief example Leos potential to use multiple 
> languages to edit data without changing enviroiment, but you are leading 
> the user on how to do the "hello world" in several languages, so he gets 
> that concept that took me so many months to understand. It would be a good 
> eye-opening script for both new and yet-unexperienced Leo users.
> 
> Im guessing that for  people who have a deeper background on programming 
> those realizations might sound foolish and delayed in time... but well, I 
> begun to learn python a few months ago to understand Leo =)
> 
> Thanks for helping me realize how to connect Leo with R!
> Im keeping the rest of the guideline for when I have gone a bit further on 
> that matter hehe
> 
> On Monday, October 14, 2013 4:02:25 PM UTC+2, Terry wrote:
> >
> > On Mon, 14 Oct 2013 01:05:30 -0700 (PDT) 
> > Fidel N <[email protected] <javascript:>> wrote: 
> >
> > > Terry, could you please share some examples of using Leo with R 
> > Statistical 
> > > Language? 
> > > Those are the kind of files I would upload together to a "Leo Sample 
> > Files" 
> > > to show how Leo can be used with anything. 
> > > I would be very interested to learn from some of your R files if 
> > possible. 
> > > Thank you. 
> >
> > There's not much too it, for both R and coffeescript, I like the node 
> > names to appear in the output like this: 
> >
> >   ### node name #################################### 
> >   
> >   <content of node> 
> >   
> >   ### next node name ############################### 
> >   
> >   <content of next node> 
> >   
> > I don't find myself using indentation across bodies (@others) in these 
> > languages. 
> >
> > So I use the button I mentioned yesterday, here's the full version 
> > which cleans up end of body whitespace as well: 
> >
> > https://github.com/leo-editor/snippets/blob/master/R_outline.py 
> >
> > I see now I was using @shadow or @nosent to edit files commented this 
> > way.  So the node names are preserved in the otherwise vanilla output 
> > by including them in the body text and periodically updating with the 
> > button - you could tie it to a pre-save hook to have it done 
> > automatically.  The hook could look for some particular @directive, 
> > getting at the new directive approach someone else brought up. 
> >
> > If your question is generally "how do you use Leo for R", then other 
> > features include: 
> >
> >   - Using the leoscreen plugin to pipe commands from body text to R 
> >     running in another window, like the Notepad++ plugin. 
> >
> >   - a @button / @rclick command to send 
> >     "viewh(summarize(<highlighted text>))" to the R session, which are 
> >     some custom R commands for displaying info about a data.frame, like 
> >     summary(). 
> >
> >   - a special abbreviation to insert rst blocks into code written for 
> >     R's knitr package, which tangles R code with rst / latex etc.  The 
> >     abbreviation "..i" expands to 
> >
> >       .. .. 
> >   
> >       This is necessary because 
> >   
> >       .. {r blockXX } 
> >
> >     which is basically a switch from R code to rst (".. .."), some text 
> >     to explain the R code (the "This is necessary because" is a 
> >     placeholder which is left highlighted after the abbreviation 
> >     executes), and then the switch back to R code, ".. {r blockXX }", 
> >     with blockXX calculated to be a new block name in the file. 
> >
> > leoscreen works like that for any app. running in a unix shell window 
> > which is running the screen shell window wrapper. 
> >
> > I suppose this could be a blog post or something, although some of the 
> > examples (specific to using the knitr package for example) are a bit 
> > esoteric. 
> >
> > Cheers -Terry 
> >
> >
> > > On Sunday, October 13, 2013 8:52:57 PM UTC+2, wgw wrote: 
> > > > 
> > > > Is there are way to put the outline structure in a user-defined 
> > comment 
> > > > format?  I want to generate a stripped down version of @file, where 
> > the 
> > > > only thing that would be indicated in the #@ comments would be the 
> > headings 
> > > > and their level.  That comment string could be user-defined, so you 
> > might 
> > > > want "#####<legal numbering>" or other.   
> > > > 
> > > > This would of course lose the directives and so on, but retain the 
> > > > headings and their hierarchy. A file that is something between the 
> > @auto 
> > > > and the @file format. (Right now, I just reformat the @file and strip 
> > > > anything that isn't a node.) 
> > > > 
> > > > For example, if the leo headings are: 
> > > > 
> > > > a 
> > > > .b 
> > > > .c 
> > > > ..d 
> > > > e 
> > > > 
> > > > then the output file would indicate the outline structure by a proper 
> > > > stacking of #@ : 
> > > > 
> > > > #@ a 
> > > > code and  comments 
> > > > #@#@ b 
> > > > code and  comments 
> > > > #@#@ c 
> > > > code and  comments 
> > > > #@#@#@ d 
> > > > code and  comments 
> > > > #@ e 
> > > > code and  comments 
> > > > 
> > > > 
> > > > Is there any easy way to achieve that output format? 
> > > > 
> > > > Thanks! 
> > > > 
> > > 
> >
> 

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to