Re: Starting intro to literate programming/ESS/Org mode?

Stephen Bond via ESS-help <[email protected]> Thu, 30 Jan 2025 14:03:47 -0500
Newsgroups gmane.emacs.ess.general
Message-ID <[email protected]>
You need to learn Rmarkdown, which is very well documented for Rstudio

https://bookdown.org/yihui/rmarkdown/

there is some help on using ESS for this at:
https://plantarum.ca/2021/10/03/emacs-tutorial-rmarkdown/

right now rmakdown is replaced with quarto, but the changes are
cosmetic if any. they are just trying to turn it into a platform for
many languages, not just R.
https://quarto.org/docs/guide/

ESS does not have the budget of Rstudio, so it is difficult to produce
tutorials.

On Thu, 2025-01-30 at 16:36 +0000, Kevin Zembower via ESS-help wrote:
> Hello, all,
> =

> I'd like to take the opportunity of taking Basic Statistics this
> semester to learn the systems and structure of literate programming.
> I
> would like to complete my homework assignments in a literate
> programming document, that shows the data used as well as the results
> created.
> =

> I'm somewhat familiar with a limited type of literate programming,
> using Emacs/ESS, LaTeX, NoWeb and knitr. Here's an example of what I
> can do already:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
> % To create the final PDF output document, in R do:
> %=C2=A0=C2=A0=C2=A0=C2=A0 library(knitr)
> %=C2=A0=C2=A0=C2=A0=C2=A0 knit2pdf("HW2.6.Rnw")
> =

> \documentclass{article}
> =

> \begin{document}
> =

> <<prelim, echo=3DFALSE>>=3D
> library(tidyverse)
> @
> =

> Question 1:
> Predicted value:
> << Q1, echo=3DTRUE, include=3DTRUE>>=3D
> Age <- 12
> Hgt <- 24.2 +2.74*Age
> Hgt
> 60 - Hgt
> @
> \end{document}
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> =

> What I'd like to learn is the technique of using Org mode, and, I
> think, RMarkdown to do literate programming without the overhead of
> learning LaTeX.
> =

> Here's an example of what I couldn't get to work (this file is
> HW2.6.org):
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> <!-- Attempt to complete MATH 231 Basic Statistics homework using
> Emacs, ESS and literate programming. -->
> =

> #+TITLE: MATH 231 HW 2.6
> #+AUTHOR: Kevin Zembower
> =

> #+PROPERTY: header-args:R :session *R* :tangle HW2.6.R :comments both
> :results raw :exports both :dir
> ~/Courses/TU_MATH231_BasicStatistics/HW
> =

> * Introduction
> ** Question 1
> This is an example of a question and answer.
> =

> #+begin_src R =

> =C2=A0 str(mtcars)
> #+end_src
> =

> #+RESULTS:
> =

> #+begin_src R=C2=A0 :file a.png
> =C2=A0 y <- rnorm(10)
> =C2=A0 plot(x, y)
> #+end_src
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> =

> When I load this file into Emacs, the status bar shows "(Org PM)"
> which, I think, indicates that it's in Org-mode as a major mode, and
> PolyMode as minor. However, keystrokes that I thought would create
> structures, such as "<s" creating the "#+begin_src R ... #+end_src"
> template don't work.
> =

> Most importantly, I'm having trouble finding sources of information
> that are up-to-date and accurate. I spent most of yesterday trying to
> find a tutorial on literate programming/Emacs/ESS/Org mode/etc, but
> most of the sources I found seemed to describe tools and plugins
> which
> other sources claimed were out of date. I couldn't follow any of the
> tutorials and get the results they described. For instance, in the
> sample above, while the source block correctly executed in the R
> buffer, the results never appeared below #+RESULTS, as I thought they
> should.
> =

> My question is, what link or source would you suggest for me to study
> and work on to try to learn the current best-practices for using
> Emacs/ESS and R to do literate programming? =

> =

> Thank you for your advice and guidance. I appreciate your efforts to
> help me.
> =

> -Kevin
> =

> ______________________________________________
> [email protected]=C2=A0mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help