emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Guidance for preparing document with code
@ 2013-05-29 15:33 SabreWolfy
  2013-05-29 16:06 ` Thomas S. Dye
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: SabreWolfy @ 2013-05-29 15:33 UTC (permalink / raw)
  To: emacs-orgmode

I'm using Org ~7.8 and would like to prepare a document for export to HTML
to make available to others to read. This document will contain heading,
text, etc., R code (for my reference) and the output of the R code. Where
should I look to learn how to do this in R? Org-babel? Is this literate
programming? I've read much about Org over the years, and I think I've
probably tried this already once before, but I'd like to know where to start
looking.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 15:33 Guidance for preparing document with code SabreWolfy
@ 2013-05-29 16:06 ` Thomas S. Dye
  2013-05-29 17:00   ` Sebastien Vauban
  2013-05-29 17:26   ` SabreWolfy
  2013-05-29 16:09 ` Thorsten Jolitz
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 14+ messages in thread
From: Thomas S. Dye @ 2013-05-29 16:06 UTC (permalink / raw)
  To: SabreWolfy; +Cc: emacs-orgmode

Aloha SabreWolfy,

SabreWolfy <sabrewolfy@gmail.com> writes:

> I'm using Org ~7.8 and would like to prepare a document for export to HTML
> to make available to others to read. This document will contain heading,
> text, etc., R code (for my reference) and the output of the R code. Where
> should I look to learn how to do this in R? Org-babel? 

Org mode should do what you want pretty much out of the box.  Note that
the exporters all changed with Org 8, so you'll want to distinguish
between the old and new exporters if you look for information on line.

> Is this literate
> programming? 

I don't think so.  The end result of literate programming is typically a
computer program rather than a document.

> I've read much about Org over the years, and I think I've
> probably tried this already once before, but I'd like to know where to start
> looking.

For your R code blocks, see the :exports header argument.  It sounds
like you'll want to set that to :exports both so you can see both your R
code and its output in the html document.

Good luck!

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 15:33 Guidance for preparing document with code SabreWolfy
  2013-05-29 16:06 ` Thomas S. Dye
@ 2013-05-29 16:09 ` Thorsten Jolitz
  2013-05-30 10:40   ` SabreWolfy
  2013-05-29 16:13 ` Nick Dokos
  2013-05-29 17:15 ` Marcin Borkowski
  3 siblings, 1 reply; 14+ messages in thread
From: Thorsten Jolitz @ 2013-05-29 16:09 UTC (permalink / raw)
  To: emacs-orgmode

SabreWolfy <sabrewolfy@gmail.com> writes:

> I'm using Org ~7.8 and would like to prepare a document for export to HTML
> to make available to others to read. This document will contain heading,
> text, etc., R code (for my reference) and the output of the R code. Where
> should I look to learn how to do this in R? Org-babel? Is this literate
> programming? I've read much about Org over the years, and I think I've
> probably tried this already once before, but I'd like to know where to start
> looking.

,----------------------------------------------------------------------------------------------------
| http://stackoverflow.com/questions/11931385/emacs-bernt-hansens-life-in-a-plaintext-sample-git-repo
`----------------------------------------------------------------------------------------------------

gives links to the html version and the org-file of a document that
demonstrates a lot of the fundamental stuff that can be done with
Org-mode, with very good explanations.

The Org manual:

,--------------------------------------------------------
| http://orgmode.org/manual/Working-With-Source-Code.html
`--------------------------------------------------------

and tutorials on Worg:

,----------------------------------------------------
| http://orgmode.org/worg/org-contrib/babel/uses.html
`----------------------------------------------------

give more explanations ..

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 15:33 Guidance for preparing document with code SabreWolfy
  2013-05-29 16:06 ` Thomas S. Dye
  2013-05-29 16:09 ` Thorsten Jolitz
@ 2013-05-29 16:13 ` Nick Dokos
  2013-05-29 17:24   ` SabreWolfy
  2013-05-29 17:15 ` Marcin Borkowski
  3 siblings, 1 reply; 14+ messages in thread
From: Nick Dokos @ 2013-05-29 16:13 UTC (permalink / raw)
  To: emacs-orgmode

SabreWolfy <sabrewolfy@gmail.com> writes:

> I'm using Org ~7.8 and would like to prepare a document for export to HTML
> to make available to others to read. This document will contain heading,
> text, etc., R code (for my reference) and the output of the R code. Where
> should I look to learn how to do this in R? Org-babel? Is this literate
> programming? I've read much about Org over the years, and I think I've
> probably tried this already once before, but I'd like to know where to start
> looking.
>

org-babel is the right tool. Getting the headers right might involve
some fiddling: there have been many question on the ML about those so
you can try searching, but if after some effort you are still running
into a wall, just post what you have, what you want to accomplish and
how your purported solution fails: there are lots of people able and
willing to help. The only thing to keep in mind is that the shorter the
example, the better: don't post your 100-page org file; extract the
example(s) that you want help with.

These are all "obvious" but I find that repetition of this sort (although
it might irk the lifers on the list) is useful.

If you are using the R code for your reference, and only presenting the
results, that's *not* literate programming: you don't have to worry
about the noweb stuff.

-- 
Nick

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 16:06 ` Thomas S. Dye
@ 2013-05-29 17:00   ` Sebastien Vauban
  2013-05-29 17:28     ` SabreWolfy
  2013-05-30 11:18     ` SabreWolfy
  2013-05-29 17:26   ` SabreWolfy
  1 sibling, 2 replies; 14+ messages in thread
From: Sebastien Vauban @ 2013-05-29 17:00 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

Thomas S. Dye wrote:
> SabreWolfy <sabrewolfy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> I'm using Org ~7.8 and would like to prepare a document for export to HTML
>> to make available to others to read. This document will contain heading,
>> text, etc., R code (for my reference) and the output of the R code. Where
>> should I look to learn how to do this in R? Org-babel? 
>
> Org mode should do what you want pretty much out of the box.  Note that
> the exporters all changed with Org 8, so you'll want to distinguish
> between the old and new exporters if you look for information on line.
>
>> Is this literate programming?
>
> I don't think so.  The end result of literate programming is typically a
> computer program rather than a document.

Just for the sake of accuracy, I'd say that "the end result of literate
programming is typically both a computer program *and* its documentation".

Getting the code out of the mixed source is called "tangling", while
generating the documentation (which shows both the code and explains it at the
same time) is called "weaving".

For the rest, you've received all the needed information so far, I guess.

Little starter for your R code:

#+BEGIN_SRC R :results graphics :file testout.png
plot(1:10, (1:10)^2)
#+END_SRC

produces (when evaluated in the buffer):

#+results:
[[file:testout.png]]

Up to you to see whether you want to export (when generating the HTML
document) the code, its results, both or none, by setting correctly the
":exports" header argument.

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 15:33 Guidance for preparing document with code SabreWolfy
                   ` (2 preceding siblings ...)
  2013-05-29 16:13 ` Nick Dokos
@ 2013-05-29 17:15 ` Marcin Borkowski
  2013-05-29 17:30   ` SabreWolfy
  3 siblings, 1 reply; 14+ messages in thread
From: Marcin Borkowski @ 2013-05-29 17:15 UTC (permalink / raw)
  To: emacs-orgmode

Dnia 2013-05-29, o godz. 15:33:51
SabreWolfy <sabrewolfy@gmail.com> napisał(a):

> I'm using Org ~7.8 and would like to prepare a document for export to
> HTML to make available to others to read. This document will contain
> heading, text, etc., R code (for my reference) and the output of the
> R code. Where should I look to learn how to do this in R? Org-babel?
> Is this literate programming? I've read much about Org over the
> years, and I think I've probably tried this already once before, but
> I'd like to know where to start looking.
> 
> 

Just my two cents: some time ago I had a problem with Org (not the
exporter, it was MobileOrg), and I was advised to install the newest
Org (8.0).  I was a bit afraid, but it turned out that the installation
went /very/ smoothly.  And since the 8.0 has the new exporter, I'd
suggest you switch, too.  (I used Elpa, but I was told that installing
from git repo is as easy as that, too.)

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 16:13 ` Nick Dokos
@ 2013-05-29 17:24   ` SabreWolfy
  2013-05-29 17:47     ` Nick Dokos
  0 siblings, 1 reply; 14+ messages in thread
From: SabreWolfy @ 2013-05-29 17:24 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos <at> gmail.com> writes:

> org-babel is the right tool. Getting the headers right might involve
> some fiddling: there have been many question on the ML about those so
> you can try searching, but if after some effort you are still running
> into a wall, just post what you have, what you want to accomplish and
> how your purported solution fails: there are lots of people able and
> willing to help. The only thing to keep in mind is that the shorter the
> example, the better: don't post your 100-page org file; extract the
> example(s) that you want help with.

Thanks. Apologies -- I meant *headers* (ie: a structured/outline-type
document), not *headings*.

> If you are using the R code for your reference, and only presenting the
> results, that's *not* literate programming: you don't have to worry
> about the noweb stuff.
> 

I wanted to include explanatory text, the R code, then the output of the
code, all in the same document. The R code will not be relevant to the
reader, but I'd like it included and executed to produce output.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 16:06 ` Thomas S. Dye
  2013-05-29 17:00   ` Sebastien Vauban
@ 2013-05-29 17:26   ` SabreWolfy
  1 sibling, 0 replies; 14+ messages in thread
From: SabreWolfy @ 2013-05-29 17:26 UTC (permalink / raw)
  To: emacs-orgmode

Hi :)

Thomas S. Dye <tsd <at> tsdye.com> writes:

> Org mode should do what you want pretty much out of the box.  Note that
> the exporters all changed with Org 8, so you'll want to distinguish
> between the old and new exporters if you look for information on line.

I haven't upgraded to Org 8 yet, but I see a later reply in this threads
mentions that it's quite easy, so I might try that first, to benefit from
the new exporter.

> For your R code blocks, see the :exports header argument.  It sounds
> like you'll want to set that to :exports both so you can see both your R
> code and its output in the html document.

Noted; thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 17:00   ` Sebastien Vauban
@ 2013-05-29 17:28     ` SabreWolfy
  2013-05-30 11:18     ` SabreWolfy
  1 sibling, 0 replies; 14+ messages in thread
From: SabreWolfy @ 2013-05-29 17:28 UTC (permalink / raw)
  To: emacs-orgmode

Hi Sebastien,

Thanks for the explanation and the example, which I'm going to use to get me
started.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 17:15 ` Marcin Borkowski
@ 2013-05-29 17:30   ` SabreWolfy
  2013-05-29 19:45     ` Marcin Borkowski
  0 siblings, 1 reply; 14+ messages in thread
From: SabreWolfy @ 2013-05-29 17:30 UTC (permalink / raw)
  To: emacs-orgmode

Hi Marcin,

Marcin Borkowski <mbork <at> wmi.amu.edu.pl> writes:

> Just my two cents: some time ago I had a problem with Org (not the
> exporter, it was MobileOrg), and I was advised to install the newest
> Org (8.0).  I was a bit afraid, but it turned out that the installation
> went /very/ smoothly.  And since the 8.0 has the new exporter, I'd
> suggest you switch, too.  (I used Elpa, but I was told that installing
> from git repo is as easy as that, too.)

I was holding off updating to Org 8, but I might do that first, as your
experience was a good one. My concern regarding updating was more related to
the long list of "gotchas" on the website about version 8 and functionality
changes.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 17:24   ` SabreWolfy
@ 2013-05-29 17:47     ` Nick Dokos
  0 siblings, 0 replies; 14+ messages in thread
From: Nick Dokos @ 2013-05-29 17:47 UTC (permalink / raw)
  To: emacs-orgmode

SabreWolfy <sabrewolfy@gmail.com> writes:

> Nick Dokos <ndokos <at> gmail.com> writes:
>
>> org-babel is the right tool. Getting the headers right might involve
>> some fiddling: there have been many question on the ML about those so
>> you can try searching, but if after some effort you are still running
>> into a wall, just post what you have, what you want to accomplish and
>> how your purported solution fails: there are lots of people able and
>> willing to help. The only thing to keep in mind is that the shorter the
>> example, the better: don't post your 100-page org file; extract the
>> example(s) that you want help with.
>
> Thanks. Apologies -- I meant *headers* (ie: a structured/outline-type
> document), not *headings*.
>

I think you used the right terminology the first time: those are usually
referred to as ``headings''.

The ``headers'' I was referring to are the header arguments in a code
block. I should have said ``header arguments'' explicitly - see e.g.

(info "(org) Working with source code")

>> If you are using the R code for your reference, and only presenting the
>> results, that's *not* literate programming: you don't have to worry
>> about the noweb stuff.
>> 
>
> I wanted to include explanatory text, the R code, then the output of the
> code, all in the same document. The R code will not be relevant to the
> reader, but I'd like it included and executed to produce output.
>

You can do that with babel: the ":exports both" header argument allows
both code and results to be exported.

We can argue whether this is literate programming but it's probably not
a useful argument: it's not black and white, there is a continuous
spectrum. As Seb explained, literate programming is (usually) about
presenting a program (usually a *large* program) in logical pieces,
interleaving the explanations with program fragments and depending on
the system to a) "tangle" all the program fragments into a program that
can actually be run without any modifications and b) "weave" the code
fragments and explanations into a document (e.g. a book).

-- 
Nick

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 17:30   ` SabreWolfy
@ 2013-05-29 19:45     ` Marcin Borkowski
  0 siblings, 0 replies; 14+ messages in thread
From: Marcin Borkowski @ 2013-05-29 19:45 UTC (permalink / raw)
  To: emacs-orgmode

Dnia 2013-05-29, o godz. 17:30:23
SabreWolfy <sabrewolfy@gmail.com> napisał(a):

> Hi Marcin,
> 
> Marcin Borkowski <mbork <at> wmi.amu.edu.pl> writes:
> 
> > Just my two cents: some time ago I had a problem with Org (not the
> > exporter, it was MobileOrg), and I was advised to install the newest
> > Org (8.0).  I was a bit afraid, but it turned out that the
> > installation went /very/ smoothly.  And since the 8.0 has the new
> > exporter, I'd suggest you switch, too.  (I used Elpa, but I was
> > told that installing from git repo is as easy as that, too.)
> 
> I was holding off updating to Org 8, but I might do that first, as
> your experience was a good one. My concern regarding updating was
> more related to the long list of "gotchas" on the website about
> version 8 and functionality changes.

Well, there might be a few rough edges, but I guess that the quality of
the new exporter might overweigh them (I don't know for sure, I don't
use Org exporter /at all/).

Also, I started with updating my Emacs to 24.3, though it was probably
not strictly necessary - but it made using Elpa easier than with v23
(it was possible then, but in v24 it Just Works™ out of the box).

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 16:09 ` Thorsten Jolitz
@ 2013-05-30 10:40   ` SabreWolfy
  0 siblings, 0 replies; 14+ messages in thread
From: SabreWolfy @ 2013-05-30 10:40 UTC (permalink / raw)
  To: emacs-orgmode

Hi Thorsten,

Thanks for the links.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Guidance for preparing document with code
  2013-05-29 17:00   ` Sebastien Vauban
  2013-05-29 17:28     ` SabreWolfy
@ 2013-05-30 11:18     ` SabreWolfy
  1 sibling, 0 replies; 14+ messages in thread
From: SabreWolfy @ 2013-05-30 11:18 UTC (permalink / raw)
  To: emacs-orgmode

Sebastien Vauban <sva-news@...> writes:

> Little starter for your R code:
> 
> #+BEGIN_SRC R :results graphics :file testout.png
> plot(1:10, (1:10)^2)
> #+END_SRC

<snip>

w00t! I exported a quick structured document, with text, code and the "png"
file as an HTML document. This is super-cool :) I should have figured out
how to this ages ago. Thanks for the example. And thanks to Carsten, /et
al./ too ;)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-05-30 11:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29 15:33 Guidance for preparing document with code SabreWolfy
2013-05-29 16:06 ` Thomas S. Dye
2013-05-29 17:00   ` Sebastien Vauban
2013-05-29 17:28     ` SabreWolfy
2013-05-30 11:18     ` SabreWolfy
2013-05-29 17:26   ` SabreWolfy
2013-05-29 16:09 ` Thorsten Jolitz
2013-05-30 10:40   ` SabreWolfy
2013-05-29 16:13 ` Nick Dokos
2013-05-29 17:24   ` SabreWolfy
2013-05-29 17:47     ` Nick Dokos
2013-05-29 17:15 ` Marcin Borkowski
2013-05-29 17:30   ` SabreWolfy
2013-05-29 19:45     ` Marcin Borkowski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).