Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
datautils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioinfo
datautils
Commits
1c68350f
Commit
1c68350f
authored
9 years ago
by
Holger Brandl
Browse files
Options
Downloads
Patches
Plain Diff
started rendr
parent
4696ef5b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/rendr/README.md
+43
-0
43 additions, 0 deletions
R/rendr/README.md
R/rendr/rend.R
+0
-0
0 additions, 0 deletions
R/rendr/rend.R
R/rendr/rendr_utils.sh
+41
-0
41 additions, 0 deletions
R/rendr/rendr_utils.sh
with
84 additions
and
0 deletions
R/rendr/README.md
0 → 100644
+
43
−
0
View file @
1c68350f
rend.R - A shell-wrapper for rmarkdown::render
===
Installation
---
Download a local copy and add it to your path using
```
targetDirectory=~/bin
wget -P $targetDirectory --no-check-certificate https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/rendr/rend.R
chmod +x $targetDirectory/rend.R
export PATH=$targetDirectory:$PATH
```
Usage
---
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 https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/rendr/rendr_utils.sh 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"
```
This diff is collapsed.
Click to expand it.
R/
spin
r/rend
e
.R
→
R/
rend
r/rend.R
+
0
−
0
View file @
1c68350f
File moved
This diff is collapsed.
Click to expand it.
R/rendr/rendr_utils.sh
0 → 100755
+
41
−
0
View file @
1c68350f
rendr
(){
## test if present in PATH
if
[
-z
"
$(
which rendr.R
)
"
]
;
then
>
&2
echo
"rendr.R is not installed. See https://github.com/holgerbrandl/datautils/tree/master/R/rendr for details"
fi
spin.R
$*
}
export
-f
spinr
rendr_snippet
(){
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."
return
fi
reportName
=
$1
tmpR
=
$(
mktemp
-d
)
/
$(
echo
$reportName
|
tr
" "
"_"
)
.R
## http://stackoverflow.com/questions/11454343/pipe-output-to-bash-function
cat
|
sed
's/#>/#'
"'"
'/g'
>
$tmpR
echo
"rendering
$tmpR
..."
shift
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment