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: > ================================= > % To create the final PDF output document, in R do: > % library(knitr) > % knit2pdf("HW2.6.Rnw") > > \documentclass{article} > > \begin{document} > > <<prelim, echo=FALSE>>= > library(tidyverse) > @ > > Question 1: > Predicted value: > << Q1, echo=TRUE, include=TRUE>>= > Age <- 12 > Hgt <- 24.2 +2.74*Age > Hgt > 60 - Hgt > @ > \end{document} > ================================================ > > 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): > ============================================= > <!-- 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 > str(mtcars) > #+end_src > > #+RESULTS: > > #+begin_src R :file a.png > y <- rnorm(10) > plot(x, y) > #+end_src > ==================================== > > 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 > > ______________________________________________ > ESS-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/ess-help ______________________________________________ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help