[Rd] RMarkdown Vignettest in R packages with child is failing in package build

Duncan Murdoch murdoch@dunc@n @ending from gm@il@com
Fri Jul 13 12:32:09 CEST 2018


On 13/07/2018 2:32 AM, Witold E Wolski wrote:
> Dear Duncan,
> 
> Thank you, got it working with your advice.
> 
> I did placed the child markdown documents into inst/ParametrizedReportsChild
> 
> And this is the code in the main vignette by which I include them:
> 
> child_docs <- "Grp2Analysis_MissingInOneCondtion.Rmd_t"
> 
> if(!sum(NAinfo$nrProteins > 0) > 0){
>    child_docs <- "Grp2Analysis_Empty.Rmd_t"
> }
> 
> child_docs <- system.file(file.path("ParametrizedReportsChild",child_docs),package
> = "SRMService")
> 
> 
> However, according to writing package vignettes
> [https://cran.r-project.org/doc/manuals/R-exts.html#Writing-package-vignettes]
> :
> "All other files needed to re-make the vignettes (such as LaTeX style
> files, BibTeX input files and files for any figures not created by
> running the code in the vignette) _must_ be in the vignette source
> directory."
> 
> So why placing those files i.e.
> Grp2Analysis_MissingInOneCondtion.Rmd_t and Grp2Analysis_Empty.Rmd_t
> in the vignettes folder and including them by:
> 
> child_docs <- "Grp2Analysis_MissingInOneCondtion.Rmd_t"
> 
> if(!sum(NAinfo$nrProteins > 0) > 0){
>    child_docs <- "Grp2Analysis_Empty.Rmd_t"
> }
> 
> , did not work?

In that paragraph, "must" is ambiguous:  it could signify a necessary 
condition, or it could signify a directive.  Perhaps in this case it is 
a directive:  even though things work, maybe the author of that 
paragraph wants you to do it in some other way.

Or perhaps necessity was intended, and it is just incorrect.

Duncan Murdoch

> 
> Have a great day,
> best regards
> Witek
> 
> 
> On 10 July 2018 at 19:52, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
>> On 10/07/2018 11:44 AM, Witold E Wolski wrote:
>>>
>>> Dear List,
>>>
>>> I am working on moving some Rmarkdown reports into the vignettes
>>> folder of a package. While I was able to solve to problem of
>>> parametrized reports in vignettes folder thanks to your invaluable
>>> help (Thank you), I am now struggling with the following problem.
>>>
>>>
>>> One of the reports which I am moving to vignettes includes the following
>>> code :
>>>
>>>
>>> ```{r}
>>> child_docs <- "Grp2Analysis_MissingInOneCondtion.Rmd_t"
>>> if(TRUE){
>>>     child_docs <- "Grp2Analysis_Empty.Rmd_t"
>>> }
>>>
>>> ```
>>>
>>> ```{r includeMissingInOne, child = child_docs}
>>> ```
>>>      # this is line 351 from the error message
>>>
>>> which depending on a test outcome includes one or the other Rmarkdown
>>> document into the main document.
>>>
>>>
>>> While this report renders executing rmarkdown::render or
>>> devtools::build_vignettes, it fails when building the package with
>>> devtools::build or R CMD build
>>> given the following error:
>>>
>>>
>>> Error in eval(x, envir = envir) : object 'child_docs' not found
>>> Warning in readLines(if (is.character(input2)) { :
>>>     cannot open file './child_docs': No such file or directory
>>> Quitting from lines 351-351 (./child_docs)
>>> Error in readLines(if (is.character(input2)) { :
>>>     cannot open the connection
>>> ERROR: installing vignettes failed
>>> * removing
>>> 'C:/Users/wolski/AppData/Local/Temp/RtmpIti891/Rinst2cec49ca2170/SRMService'
>>> In R CMD INSTALL
>>>
>>
>>
>> Since you didn't give a path to that file, it will use the current working
>> directory, which might be a temporary directory used during the package
>> installation.  Since you want this to work as a vignette, you need to
>> include the child docs in your package.  One way to do that is to put them
>> in a new directory called "inst/children", which will be installed to
>> "children" when your package is installed.  Then the vignette can find the
>> file as
>>
>>      system.file(file.path("children", child_docs), package = "yourpackage")
>>
>> You could also put them in the "vignettes" directory, but there are special
>> rules for how files there are installed or not, so I'd recommend against it.
>>
>> Duncan Murdoch
> 
> 
>



More information about the R-devel mailing list