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
20315f36
Commit
20315f36
authored
9 years ago
by
Holger Brandl
Browse files
Options
Downloads
Patches
Plain Diff
add fake yaml header at top of script; added option to show uncolloapsed code-chunks
parent
97621742
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/rendr/rend.R
+12
-8
12 additions, 8 deletions
R/rendr/rend.R
with
12 additions
and
8 deletions
R/rendr/rend.R
+
12
−
8
View file @
20315f36
...
...
@@ -17,7 +17,8 @@ Usage: rend.R [options] <r_script> [<quoted_script_args>]
Options:
--toc Add a table of contents
-c Cache results
-e Show Code
-e Add collapsed code chunks
-E Add uncollapsed code chunks
-w Show warnings
-m Show Messages
--keep Keep generated Rmd and md files
...
...
@@ -37,21 +38,21 @@ if(!file.exists(r_script)){
## postfix a default empty yaml header
tmpScript
<-
tempfile
(
fileext
=
".R"
)
#tmpScript <- "tt.R"
## remove sheband and comment-only lines from source document
#file.copy(r_script, tmpScript)
system
(
paste
(
"cat "
,
r_script
,
" | grep -Ev '^#+$' | grep -Fv '#!/usr/bin/env Rscript' >"
,
tmpScript
))
## add yaml header (will be ignored if already present
metadata
<-
paste
(
'\n'
,
metadata
<-
paste
0
(
'#\'---\n'
,
'#\'title: ""\n'
,
'#\'author: ""\n'
,
'#\'date: ""\n'
,
'#\'---\n'
,
sep
=
""
)
cat
(
metadata
,
file
=
tmpScript
,
append
=
TRUE
)
'#\'---\n'
)
cat
(
metadata
,
file
=
tmpScript
)
system
(
paste
(
"cat "
,
r_script
,
" | grep -Ev '^#+$' | grep -Fv '#!/usr/bin/env Rscript' >>"
,
tmpScript
)
)
# see http://stackoverflow.com/questions/17341122/link-and-execute-external-javascript-file-hosted-on-github
...
...
@@ -59,7 +60,10 @@ cat(metadata, file = tmpScript, append = TRUE)
jsAddons
<-
tempfile
(
fileext
=
".js"
)
#cat("<script src='https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/rendr/toggle_code_sections.js' type='application/javascript'></script>", file=jsAddons)
cat
(
"<script src='https://code.jquery.com/jquery-2.1.4.min.js' type='application/javascript'></script>"
,
file
=
jsAddons
)
cat
(
"<script src='http://cdn.rawgit.com/holgerbrandl/datautils/master/R/rendr/toggle_code_sections.js' type='application/javascript'></script>"
,
file
=
jsAddons
,
append
=
T
)
if
(
opts
$
e
){
cat
(
"<script src='http://cdn.rawgit.com/holgerbrandl/datautils/master/R/rendr/toggle_code_sections.js' type='application/javascript'></script>"
,
file
=
jsAddons
,
append
=
T
)
}
## does not work yet
...
...
@@ -88,7 +92,7 @@ opts_chunk$set(
cache
=
opts
$
c
,
message
=
opts
$
m
,
warning
=
opts
$
w
,
echo
=
opts
$
e
,
echo
=
opts
$
e
|
opts
$
E
,
out.width
=
'100%'
)
...
...
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