From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: Using R in Org mode with several sourced files Date: Tue, 2 Feb 2010 20:26:43 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0389298591==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcNXG-00042P-SD for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 13:31:38 -0500 Received: from [199.232.76.173] (port=38366 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcNXF-00042E-DF for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 13:31:37 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NcNXC-0008FB-4R for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 13:31:37 -0500 Received: from mail-ew0-f228.google.com ([209.85.219.228]:41209) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NcNTZ-0007n4-Kp for emacs-orgmode@gnu.org; Tue, 02 Feb 2010 13:31:34 -0500 Received: by ewy28 with SMTP id 28so385502ewy.8 for ; Tue, 02 Feb 2010 10:26:44 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: Dan Davison , emacs-orgmode@gnu.org --===============0389298591== Content-Type: multipart/alternative; boundary=0016e6d566986392c8047ea23e75 --0016e6d566986392c8047ea23e75 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Feb 2, 2010 at 8:03 PM, Thomas S. Dye wrote: > > On Feb 2, 2010, at 3:35 AM, Rainer M Krug wrote: > > Hi > > Following a discussion about how one could create a TODO list in ESS (see > below), Thomas Dye and Dan Davison suggested to look into org-mode and > org-babel and it looks really interesting. I just have one aspect, which > would be more difficult with my workflow. Let me explain. I am writing > fairly complex simulations, and I prefer to keep functions for different > aspects of the simulation in different files. Therefore I have several > files, each one containing R code, which is sourced from a main file, which > then sets the simulation up, which I then can start with calling > simulateIt() in R. I could use .org files and tangle the code, but, as I am > not that organised, I even forget sometimes to save before I source the file > and therefore still work with the old version - this would be more > difficult, if I had to tangle each file in addition to the saving (Ctrl-x s > saves all files - very useful for me!). > > One option would be to combine all actual files into a single one, and then > tangle in different .R files, but I somehow do not like the idea of having > one HUGE file, with all the code, which then will be tangled into several .R > files. > So I would like to have several .org files, where each one will be tangled > into a separate .R file, which then will be sourced from a final main file. > As I understand org-mode, I could still have a single TODO list, based on > the agenda in org-mode. > > So my question is, if this process could be automated. One idea was a kind > of a "make file", in which I specify: > tangle file1.org > tangle file2.org > tangle file3.org > tangle fileAll.org > > These would then result in the files attached, which then can be used from > fileAll.R > > Another idea was to have emacs automatically tangle the file after saving. > > But I am sure there are also other possibilities. > > I have to say, I am absolutely new to org-mode, and know nearly nothing > about lisp. > > Cheers, > > Rainer > > > ---------- Forwarded message ---------- > From: Dan Davison > Date: Mon, Feb 1, 2010 at 9:59 PM > Subject: Re: Fwd: [ESS] generating TODO list? > To: Rainer M Krug > Cc: "Thomas S. Dye" > > > [...] > > Sure, when you change the code in the org file, you have to re-run > > org-babel-tangle before you run your new R code. > > > > > > Ant this is the critical point: I can save all files which need to be > saved in > > ESS by Ctrl-x s (or was it Ctrl-x Ctrl-s ? I always do both). But having > > manually to go through all files, is something I am likely to forget. If > I > > could tangle all files with one command, that wouls work (I have about 10 > files > > for the project which are then sourced...). Could I combine the save-all > with a > > tangle-all, or have the saving action automatically followed by a > tangling (if > > it is an org file)? > > > > > > But that's just one possibility. Another would be simply to tangle > all > > the blocks of R code to the same file. Then when you run that file, > you > > know that your function definitions will be up to date. > > > > > > It is quite strange, that there is no possibility to script emacs from > org mode > > like all the other languages? because that would be perfect for this. > > > I am certain that there is going to be a good solution for all your > concerns! I think you want to be thinking along the lines of maintaining > a _single_ org file for your project, and either including the code in > different subtrees of that file, or referring to external files from > within that file. But if the right solution doesn't doesn't already > exist, and it's a good idea, then someone will cook it up in > elisp. Could we move this discussion to the org-mode list? If you > describe what you want to do, with a toy example if that's helpful, then > I believe you will see that problems do not remain without solution for > very long on emacs-orgmode@gnu.org. > > Meanwhile, have a look at this > > http://doc.norang.ca/org-mode.html > > to see some of what org-mode can do (the website itself is made in > org-mode of course). > > Dan > > > > > > > > > > By the way, have you tried out the export facilities of org-mode? > Have a > > look at the html export of the above org file [C-c C-e (org-export) > > brings up the export options]. You can create links in the org file > to > > graphical output from R and these graphs will be included in the > > exported HTML/LaTeX. > > > > > > No - I just discovered the org-mode yesterday. > > > > Cheers, > > > > Rainer > > > > > > > > Dan > > > > > > > > If that could be done, it would be a perfect example, how one could > use > > > org-babel in real R programming. The other option, would be a "make > file" > > > equivalent, which contains all the "tangle file ..." commands, and > which > > could > > > be executed in the block above. > > > > > > > > > > > > And it's also worth looking at the noweb-style references for > > assembling > > > > > > different code blocks into a single code block. So with > reference to > > the > > > distinction between "source is real" vs. "R objects are real", > from > > > the org-babel point of view the org-mode files are real and > contain > > the > > > source code along with essential project development and > planning > > notes, > > > and the .R files are an ephemeral product of the org-mode > source. > > > > > > > > > As I said, it makes perfect sense, but the problem is the > additional step > > > needed. If this could be avoided (e.g. "make file") I would very > likely > > use the > > > org-mode. > > > > > > Thanks for your very helpful comments, > > > > > > Rainer > > > > > > > > > > > > Dan > > > > > > http://orgmode.org/worg/org-contrib/babel/intro.php# > > literate-programming > > > http://orgmode.org/worg/org-contrib/babel/reference.php# > > > function-org-babel-tangle > > > > > > > > > > > > > > > > > > > > I will be looking into it anyway, because it REALLY looks > very > > > useful. > > > > > > > > > > > > > > > > You might want to join the Org-mode mailing list. > The > > authors of > > > > Org-babel, Dan Davison and Eric Schulte, both respond > to > > > questions > > > > there. Also, there are several Org-babel users there > who > > are > > > much > > > > better than I am at figuring out why things aren't > working > > right. > > > > > > > > What happens when you try Ctrl-C ' while in a code > block? > > If > > > Org-babel > > > > is initialized then this should take you to a new > window > > with ESS > > > as > > > > the editing mode. > > > > > > > > > > > > Well - I used Ctrl-c ` instead of Ctrl-c ' -- working > now. > > > > > > > > > > > > Thanks a lot, > > > > > > > > Rainer > > > > > > > > > > > > > > > > > > > > All the best, > > > > Tom > > > > > > > > > > > > > > > -- > NEW GERMAN FAX NUMBER!!! > > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, > UCT), Dipl. Phys. (Germany) > > Centre of Excellence for Invasion Biology > Natural Sciences Building > Office Suite 2039 > Stellenbosch University > Main Campus, Merriman Avenue > Stellenbosch > South Africa > > Cell: +27 - (0)83 9479 042 > Fax: +27 - (0)86 516 2782 > Fax: +49 - (0)321 2125 2244 > email: Rainer@krugs.de > > Skype: RMkrug > Google: R.M.Krug@gmail.com > > > > > Aloha Rainer, > > I'm interested to know why you're adverse to one HUGE file. I like one > HUGE file for the simplicity it brings to the often onerous task of > organizing a project. In a paper on Statistical Analyses and > Reproducible Research, > Robert Gentleman and Duncan Temple Lang develop the idea of a compendium > and argue for its utility in what appears to be your kind of application ( > http://www.bepress.com/bioconductor/paper2). To my mind, one of the > strong features of Org-babel/Org-mode is that it almost effortlessly creates > a compendium. Also, once you become accustomed to using Org-mode and get > the hang of folding and unfolding headings, it very quickly maps onto the > old division of material into separate files. > I must admit that, after playing around with org-mode and org-babel, I start thinking along the same lines. As you mention, the structuring makes it ppossible to have each section or subsection represent what I would have put in one single file. I am also thinking that locating the source code of a function in a different file became more and more difficult. OK - I'll play with it over the next few days, and see what is happening. Interesting article - and I agree with the idea of a "compendium". Cheers and thanks, Rainer > > All the best, > Tom > > > > Thomas S. Dye, Ph.D. > > T. S. Dye & Colleagues, Archaeologists, Inc. > > Phone: (808) 529-0866 Fax: (808) 529-0884 > > http://www.tsdye.com > > > -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax: +27 - (0)86 516 2782 Fax: +49 - (0)321 2125 2244 email: Rainer@krugs.de Skype: RMkrug Google: R.M.Krug@gmail.com --0016e6d566986392c8047ea23e75 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Tue, Feb 2, 2010 at 8:03 PM, Thomas S= . Dye <tsd@tsdye.com<= /a>> wrote:

On Feb 2, 2010, at 3:35 AM, Rainer M Krug wrote:

Hi

=
=A0Following a discussion about how one could create a TODO list in ESS (se= e below), Thomas Dye and Dan Davison suggested to look into org-mode and or= g-babel and it looks really interesting. I just have one aspect, which woul= d be more difficult with my workflow. Let me explain. I am writing fairly c= omplex simulations, and I prefer to keep functions for different aspects of= the simulation in different files. Therefore I have several files, each on= e containing R code, which is sourced from a main file, which then sets the= simulation up, which I then can start with calling simulateIt() in R. I co= uld use .org files and tangle the code, but, as I am not that organised, I = even forget sometimes to save before I source the file and therefore still = work with the old version - this would be more difficult, if I had to tangl= e each file in addition to the saving (Ctrl-x s saves all files - very usef= ul for me!).=A0

One option would be to combine all actual files into a= single one, and then tangle in different .R files, but I somehow do not li= ke the idea of having one HUGE file, with all the code, which then will be = tangled into several .R files.=A0
So I would like to have several .org files, where each one will be ta= ngled into a separate .R file, which then will be sourced from a final main= file. As I understand org-mode, I could still have a single TODO list, bas= ed on the agenda in org-mode.

So my question is, if this process could be automated.= One idea was a kind of a "make file", in which I specify:
<= div>tangle file1.org
tangle file2.org
tangle file3.org


Another idea was to have emacs automatically tangle the= file after saving.

But I am sure there are also = other possibilities.

I have to say, I am absolutel= y new to org-mode, and know nearly nothing about lisp.

Cheers,

Rainer

=
---------- Forwarded message ----------
F= rom: Dan Davison <davison@stats.ox.= ac.uk
>
Date: Mon, Feb 1, 2010 at 9:59 PM
Subject: Re: Fwd: [ESS] generating TO= DO list?
To: Rainer M Krug <r.m.krug@gmail.com>
Cc: "Thomas S. Dye" = <tsd@tsdye.com>= ;


[...]
> =A0 =A0 Sure, when you change the code in the = org file, you have to re-run
> =A0 =A0 org-babel-tangle before you r= un your new R code.
>
>
> Ant this is the critical poi= nt: I can save all files which need to be saved in
> ESS by Ctrl-x s (or was it Ctrl-x Ctrl-s ? I always do both). But hav= ing
> manually to go through all files, is something I am likely to = forget. If I
> could tangle all files with one command, that wouls w= ork (I have about 10 files
> for the project which are then sourced...). Could I combine the save-= all with a
> tangle-all, or have the saving action automatically fol= lowed by a tangling (if
> it is an org file)?
>
>
> =A0 =A0 But that's just one possibility. Another would be simply = to tangle all
> =A0 =A0 the blocks of R code to the same file. Then = when you run that file, you
> =A0 =A0 know that your function defini= tions will be up to date.
>
>
> It is quite strange, that there is no possibility t= o script emacs from org mode
> like all the other languages? because= that would be perfect for this.=A0


I am certain that t= here is going to be a good solution for all your
concerns! I think you want to be thinking along the lines of maintaining a _single_ org file for your project, and either including the code in different subtrees of that file, or referring to external files from
within that file. But if the right solution doesn't doesn't alread= y
exist, and it's a good idea, then someone will cook it up in
= elisp. Could we move this discussion to the org-mode list? If you
descr= ibe what you want to do, with a toy example if that's helpful, then
I believe you will see that problems do not remain without solution for very long on e= macs-orgmode@gnu.org.

Meanwhile, have a look at this

= http://doc= .norang.ca/org-mode.html

to see some of what org-mode can do (the website itself is made in org-mode of course).

Dan


>
>
>
> =A0 =A0 By the w= ay, have you tried out the export facilities of org-mode? Have a
> =A0 =A0 look at the html export of the above org file [C-c C-e (org-e= xport)
> =A0 =A0 brings up the export options]. You can create links= in the org file to
> =A0 =A0 graphical output from R and these grap= hs will be included in the
> =A0 =A0 exported HTML/LaTeX.
>
>
> No - I just d= iscovered the org-mode yesterday.
>
> Cheers,
>
&g= t; Rainer
> =A0
>
>
> =A0 =A0 Dan
>
= > =A0 =A0 >
> =A0 =A0 > If that could be done, it would be a perfect example, ho= w one could use
> =A0 =A0 > org-babel in real R programming. The = other option, would be a "make file"
> =A0 =A0 > equiva= lent, which contains all the "tangle file ..." commands, and whic= h
> =A0 =A0 could
> =A0 =A0 > be executed in the block above. > =A0 =A0 > =A0
> =A0 =A0 >
> =A0 =A0 >
&g= t; =A0 =A0 > =A0 =A0 And it's also worth looking at the noweb-style = references for
> =A0 =A0 assembling
> =A0 =A0 >
> =A0 =A0 > =A0 =A0 different code blocks into= a single code block. So with reference to
> =A0 =A0 the
> = =A0 =A0 > =A0 =A0 distinction between "source is real" vs. &qu= ot;R objects are real", from
> =A0 =A0 > =A0 =A0 the org-babel point of view the org-mode files a= re real and contain
> =A0 =A0 the
> =A0 =A0 > =A0 =A0 sour= ce code along with essential project development and planning
> =A0 = =A0 notes,
> =A0 =A0 > =A0 =A0 and the .R files are an ephemeral = product of the org-mode source.
> =A0 =A0 >
> =A0 =A0 >
> =A0 =A0 > As I said, i= t makes perfect sense, but the problem is the additional step
> =A0 = =A0 > needed. If this could be avoided (e.g. "make file") I wo= uld very likely
> =A0 =A0 use the
> =A0 =A0 > org-mode.
> =A0 =A0 >=
> =A0 =A0 > Thanks for your very helpful comments,
> =A0 = =A0 >
> =A0 =A0 > Rainer
> =A0 =A0 >
> =A0 = =A0 >
> =A0 =A0 >
> =A0 =A0 > =A0 =A0 Dan
> =A0 =A0 >
> =A0 =A0 > = =A0 =A0 http://orgmode.org/worg/org-contrib/babel/intro.php# > =A0 =A0 literate-programming
> =A0 =A0 > =A0 =A0 http://orgmode.org/worg/org-contrib/= babel/reference.php#
> =A0 =A0 > =A0 =A0 function-org-babel-t= angle
> =A0 =A0 >
> =A0 =A0 >
> =A0 =A0 >
> =A0 =A0 >
> =A0= =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 > =A0 =A0 I will be= looking into it anyway, because it REALLY looks very
> =A0 =A0 >= =A0 =A0 useful.
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 >
>= =A0 =A0 > =A0 =A0 > =A0 =A0 =A0 =A0 You might want to join the Org-m= ode mailing list. =A0The
> =A0 =A0 authors of
> =A0 =A0 > = =A0 =A0 > =A0 =A0 =A0 =A0 Org-babel, Dan Davison and Eric Schulte, both = respond to
> =A0 =A0 > =A0 =A0 questions
> =A0 =A0 > =A0 =A0 > =A0= =A0 =A0 =A0 there. =A0Also, there are several Org-babel users there who > =A0 =A0 are
> =A0 =A0 > =A0 =A0 much
> =A0 =A0 >= =A0 =A0 > =A0 =A0 =A0 =A0 better than I am at figuring out why things a= ren't working
> =A0 =A0 right.
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 &g= t; =A0 =A0 > =A0 =A0 =A0 =A0 What happens when you try Ctrl-C ' whil= e in a code block?
> =A0 =A0 =A0If
> =A0 =A0 > =A0 =A0 Org= -babel
> =A0 =A0 > =A0 =A0 > =A0 =A0 =A0 =A0 is initialized th= en this should take you to a new window
> =A0 =A0 with ESS
> =A0 =A0 > =A0 =A0 as
> =A0 =A0 &g= t; =A0 =A0 > =A0 =A0 =A0 =A0 the editing mode.
> =A0 =A0 > =A0= =A0 >
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 = > =A0 =A0 Well - I used Ctrl-c ` instead of Ctrl-c ' -- working now.=
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 >
>= =A0 =A0 > =A0 =A0 > =A0 =A0 Thanks a lot,
> =A0 =A0 > =A0 = =A0 >
> =A0 =A0 > =A0 =A0 > =A0 =A0 Rainer
> =A0 =A0= > =A0 =A0 >
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 >= =A0 =A0 >
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 > =A0 =A0 = =A0 =A0 All the best,
> =A0 =A0 > =A0 =A0 > =A0 =A0 =A0 =A0 To= m
> =A0 =A0 > =A0 =A0 >
> =A0 =A0 > =A0 =A0 >
= > =A0 =A0 > =A0 =A0 >


--
NEW GERMAN FAX NUMBER!!!

Rainer M. Krug, PhD (Conservatio= n Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
=
Centre of Excellence for Invasion Biology
Natural Sciences Building=
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenu= e
Stellenbosch
South Africa

Cell: =A0 =A0 =A0 =A0 =A0 +27 - (0= )83 9479 042
Fax: =A0 =A0 =A0 =A0 =A0 =A0+27 - (0)86 516 2782
Fax: = =A0 =A0 =A0 =A0 =A0 =A0+49 - (0)321 2125 2244
email: =A0 =A0 =A0 =A0 =A0Rainer@krugs.de

Skype: =A0 =A0 =A0 =A0 =A0RMkrug
Google: = =A0 =A0 =A0 =A0 R.M= .Krug@gmail.com

<file1.R><file2.R>= <file3.R><fileAll.R>

Aloha Rainer,

I'm interested to kno= w why you're adverse to one HUGE file. =A0I like one HUGE file for the = simplicity it brings to the often onerous task of organizing a project. =A0= In a paper on=A0Statistical Analyses and Reproducible=A0Research,=A0
Robert Gentleman and Duncan Temple Lang develop the idea of a compend= ium and argue for its utility in what appears to be your kind of applicatio= n (http://www.bepress.com/bioconductor/paper2). =A0To my mind, one of the= strong features of Org-babel/Org-mode is that it almost effortlessly creat= es a compendium. =A0Also, once you become accustomed to using Org-mode and = get the hang of folding and unfolding headings, it very quickly maps onto t= he old division of material into separate files.

I must admit that, after playing aro= und with org-mode and org-babel, I start thinking along the same lines. As = you mention, the structuring makes it ppossible to have each section or sub= section represent what I would have put in one single file. I am also think= ing that locating the source code of a function in a different file became = more and more difficult. OK - I'll play with it over the next few days,= and see what is happening.

Interesting article - and I agree with the idea of a &q= uot;compendium".

Cheers and thanks,

Rainer

=A0

All the best,
=
Tom



Thomas = S. Dye, Ph.D.

T. S. Dye &= ; Colleagues, Archaeologists, Inc.

Phone: (808) 529-0866 Fax: (808) 529= -0884

http://www.tsdye.com





--
NEW GERMAN FAX NUMBER!!!

Rainer M. Krug, Ph= D (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys.= (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building<= br>Office Suite 2039
Stellenbosch University
Main Campus, Merriman Av= enue
Stellenbosch
South Africa

Cell: =A0 =A0 =A0 =A0 =A0 +27 -= (0)83 9479 042
Fax: =A0 =A0 =A0 =A0 =A0 =A0+27 - (0)86 516 2782
Fax: =A0 =A0 =A0 =A0 = =A0 =A0+49 - (0)321 2125 2244
email: =A0 =A0 =A0 =A0 =A0Rainer@krugs.de

Skype: =A0 =A0 =A0 =A0 =A0RMk= rug
Google: =A0 =A0 =A0 =A0 R.M.Kr= ug@gmail.com

--0016e6d566986392c8047ea23e75-- --===============0389298591== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0389298591==--