| Crates.io | rmdh |
| lib.rs | rmdh |
| version | 0.1.1 |
| created_at | 2025-02-21 10:05:14.132819+00 |
| updated_at | 2025-02-21 10:05:14.132819+00 |
| description | R Markdown helper toolsuite |
| homepage | |
| repository | https://codeberg.org/tropf/rmdh |
| max_upload_size | |
| id | 1563900 |
| size | 94,677 |
rmdh is a simple toolkit to work with R Markdown documents.
It collects a bunch of small usecases like genrating, rendering or updating R Markdown documents that commonly occur (for me).
R Markdown is a format that interleaves Markdown text and R code. For a more fully-featured experience use RStudio.
rmdh implements the following subcommands:
new: Create new R Markdown (.Rmd) document from templatepreview: Generate HTML previewrender: Render R Markdown filerdata: Populate .RData as if R code in given .Rmd file would have been executedselfcheck: Check if R can be launched and has required packagesUse --help to get further information on the commands.
# this generates the new file doc.Rmd and fills it with the template from src/template.Rmd
$ rmdh new doc.Rmd
# renders doc.Rmd and opens in browser
$ rmdh preview --watch doc.Rmd
opening outfile at /tmp/rmdh-1z6rEyq8.html
opened
# The document is now opened in your default browser.
# You can edit doc.Rmd, and the file in the browser will get updated automatically.
# (You still have to reload manually, e.g. with F5!)
# press Ctrl+C to exit
^C
# render to doc.html
$ rmdh render doc.Rmd
rendering doc.Rmd
done
Assume you have an .Rmd document which sets some variables.
You can populate an .Rdata file with its contents to work interactively with that state use rmdh rdata:
$ cat doc.Rmd
---
title: "Document"
output: html_document
---
\```{r}
foo <- 3
\```
$ rmdh rdata doc.Rmd
generating .Rdata
done
# now just open R regularly, and a session with the state of the Rmd will be loaded
$ R
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
[...]
[Previously saved workspace restored]
> foo
[1] 3
rmdh works by calling the Rscript binary internally and executing R programs.
Ensure that this binary work, and that you installed all required packages, including knitr and rmarkdown.
rmdh selfcheck can also do this automatically for you.
If everything is working, it should print:
$ rmdh selfcheck
test: launch Rscript binary...OK
test: load R packages...OK
test: rendering template document...OK
all checks passed
If this works, but your use case still does not work, please open an issue.
Statically linked packages (.deb, .rpm, .tar) and binaries for x86 and ARM are available on the releases page.
Files are signed with my key.
# to install permanently
nix profile install git+https://codeberg.org/tropf/rmdh
# alternatively, to get a one-off shell
nix shell git+https://codeberg.org/tropf/rmdh
cargo install --git https://codeberg.org/tropf/rmdh
In general, this is a thin wrapper around some R functions called via Rscript.
It is not checked against wonky strings, so some input might not be escaped and not behave predictably.
The installation has to copy the following items:
rmdh binaryCompletion and man page are generated at build time by build.rs into the directory given by the environment variable GEN_ARTIFACTS.
For them, the feature cli_extra has to be enabled.
rmdh is available under GPLv3+ (GPL-3.0-or-later).
Find this project online at Codeberg.