Closed chatchavan closed 9 years ago
Did you have a call to
library("knitr")
in your checkpoint project?
We don't treat knitr
different from any other package. If checkpoint()
finds knitr
, it will install it.
Yes, I have that line in the source code.
The problem was that checkpoint
skipped parsing the .Rmd
file in the first place. Therefore, any library listed in that file aren't installed.
I'm not sure I understand. In principle, your library(knitr)
should be discovered and installed if you have this statement in any .R
file.
To build a knitr
file from code, this has to be in a .R
script, IIUC.
Can you share a link to your project, so I can understand better what's happening?
You can find a minimal project that produces error here: https://www.dropbox.com/sh/3ucvdjlefbkk6zd/AABemV-LTsOtw8x7PBemObDBa?dl=0
Further development: I found that the problem happens only when I use RStudio GUI to compile the markdown. It gives the following error in R Markdown output:
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-1
processing file: source.Rmd
Quitting from lines 7-10 (source.Rmd)
Error in library(knitr) : there is no package called 'knitr'
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> library
Execution halted
However, with the same project, if I compile it with the following commands, checkpoint
install knitr
and parse the .Rmd
files correctly.
library(knitr)
library(markdown)
knit('source.Rmd', 'output.md')
@chatchavan, thank you for this additional information.
As far as I can tell, this is documented and expected behaviour.
To knit a file, you need to have library(knitr)
at the top of your script. So, when you include this, checkpoint()
works correctly, as you demonstrate.
Can we close this issue? If not, can you please provide some additional information about the use case you have in mind?
Could you point me to where this documentation is? Before I opened this issue, I searched about the problem, but couldn't find it in either the generated R doc, README.md, or http://projects.revolutionanalytics.com/rrt/.
Afterwards, you may close this issue.
The purpose of checkpoint()
is to install only the packages it discovers by searching for library()
, require()
, package::foo()
and package:::foo()
.
In this case, your scripts is dependent on knitr
, so when you call library(knitr)
in any R script in your project, checkpoint()
finds and installs it.
I'm open for any suggestions on how the documentation can be improved. Can you please make a suggestion on what exactly you want us to add? Pull requests are welcome!
@andrie does checkpoint parse Rmds? Sorry I forgot if we dropped that feature at some point. I think if it does, it makes sense to add knitr to the list of packages to be installed, whether it's explicitly loaded or not, whnever an Rmd is present in a project. I see it as a way of rounding out Rmd support. What's the point of parsing Rmds, if there's no way of compiling them? Whether it is in a script (which we support) or from RStudio (which we don't), an Rmd requires knitr to be of any use. As far as the docs, I think once you start to document what a package doesn't do, it's a slippery slope. If it's not documented, assume it's not available.
@piccolbo Good suggestions, thank you.
To answer your question: checkpoint
parses .Rmd
files if knitr
is installed.
I think it does in fact make sense to add knitr
and rmarkdown
automatically into the repository if we encounter .Rmd
files. I'll open a new issue to capture this.
I use
checkpoint()
in my R Markdown (.Rmd) file to create a script for other experimenters to reproduce the analysis. However,knitr
wasn't installed in the snapshot folder (under ~/.checkpoint). As a result, the .Rmd file wasn't parsed for required libraries and fails to run.It seems that
knitr
is loaded, but not installed (see the console output below). There's noknitr
in~/.checkpoint/2015-02-12/lib/x86_64-apple-darwin13.4.0/3.1.2/
.Quick fix: Manually install
knitr
within the checkpoint environment allowscheckpoint
to work correctly.Why it's still a problem: Although this solves problem in my computer, I'd expect anybody who use my script to reproduce the analysis to be able to knit the .Rmd without messing in the console.