Commit 1c68350f authored by Holger Brandl's avatar Holger Brandl
Browse files

started rendr

parent 4696ef5b
rend.R - A shell-wrapper for rmarkdown::render
Download a local copy and add it to your path using
wget -P $targetDirectory --no-check-certificate
chmod +x $targetDirectory/rend.R
export PATH=$targetDirectory:$PATH
To use it from a shell you can call rend.R directly with a script as argument.
rend.R MyScript.R
or for Rmd
rend.R MyScript.Rmd
The report will be created in the current working directory. To learn about options just call `rend.R --help`
In case you want to render R snippets you can source a small bash function that wraps rend.R
source <(curl 2>&1 2>/dev/null)
Now you can spin R snippets by piping them into `spinsnip`
echo "require(ggplot2); ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()" | rendr_snippet "my_report"
## test if present in PATH
if [ -z "$(which rendr.R)" ]; then
>&2 echo "rendr.R is not installed. See for details"
spin.R $*
export -f spinr
if [ $# -lt 1 ]; then
>&2 echo "Usage: rendr_snippet <report name> [other args]*"
>&2 echo "The R snippet to be spinned will be read from standard input."
tmpR=$(mktemp -d)/$(echo $reportName | tr " " "_").R
cat | sed 's/#>/#'"'"'/g' > $tmpR
echo "rendering $tmpR..."
rendr -e $tmpR $*
# rm -r $(dirname $tmpR)
rm ${tmpR}
export -f spinsnip
## usage example
# echo '
# > # test report
# 1+1;
# ggplot(iris, aes(Sepal.Width) + geom_histogram()
# ' | spinsnip some_report
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment