Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
legTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
leg
legTools
Commits
cd8079dc
Commit
cd8079dc
authored
9 years ago
by
Fernando Mayer
Browse files
Options
Downloads
Patches
Plain Diff
Create function to run all chunks in a Rmd file
parent
8bd89ffb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/runAllChunks.R
+34
-0
34 additions, 0 deletions
R/runAllChunks.R
man/runAllChunks.Rd
+31
-0
31 additions, 0 deletions
man/runAllChunks.Rd
with
65 additions
and
0 deletions
R/runAllChunks.R
0 → 100644
+
34
−
0
View file @
cd8079dc
#' @title Run all chunks in a Rmd file
#'
#' @name runAllChunks
#'
#' @description This function was developed to run all chunks in a knitr
#' Rmd (R markdown) file at once. Mainly for exploring and debugging
#' purposes.
#'
#' @param Rmd the name of the Rmd file.
#'
#' @param envir the environment in which the chunks will be
#' evaluated. By default it is the GlobalEnv.
#'
#' @references This function was based on this
#' \href{http://stackoverflow.com/questions/24753969/knitr-run-all-chunks-in-an-rmarkdown-document}{SO
#' thread}.
#'
#' @return Objects created in the chunks from the Rmd file.
#'
#' @import knitr
#'
#' @author Fernando Mayer, \email{fernando.mayer@@ufpr.br}
#'
#' @export
runAllChunks
<-
function
(
Rmd
,
envir
=
globalenv
()){
if
(
!
requireNamespace
(
"knitr"
,
quietly
=
TRUE
)){
stop
(
"`knitr` needed for this function to work. Please install it."
,
call.
=
FALSE
)
}
tempR
<-
tempfile
(
tmpdir
=
"."
,
fileext
=
".R"
)
on.exit
(
unlink
(
tempR
))
purl
(
Rmd
,
output
=
tempR
)
sys.source
(
tempR
,
envir
=
envir
)
}
This diff is collapsed.
Click to expand it.
man/runAllChunks.Rd
0 → 100644
+
31
−
0
View file @
cd8079dc
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/runAllChunks.R
\name{runAllChunks}
\alias{runAllChunks}
\title{Run all chunks in a Rmd file}
\usage{
runAllChunks(Rmd, envir = globalenv())
}
\arguments{
\item{Rmd}{the name of the Rmd file.}
\item{envir}{the environment in which the chunks will be
evaluated. By default it is the GlobalEnv.}
}
\value{
Objects created in the chunks from the Rmd file.
}
\description{
This function was developed to run all chunks in a knitr
Rmd (R markdown) file at once. Mainly for exploring and debugging
purposes.
}
\author{
Fernando Mayer, \email{fernando.mayer@ufpr.br}
}
\references{
This function was based on this
\href{http://stackoverflow.com/questions/24753969/knitr-run-all-chunks-in-an-rmarkdown-document}{SO
thread}.
}
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