From murdoch@dunc@n @ending from gm@il@com  Fri Sep 14 11:19:35 2018
From: murdoch@dunc@n @ending from gm@il@com (Duncan Murdoch)
Date: Fri, 14 Sep 2018 05:19:35 -0400
Subject: [Rd] Problem building rmarkdown vignettes with child
In-Reply-To: <CAAjnpdjfMg+07bh+o0n1FTEZTp7dYm=6BTCTFD3MBRtfA0MvZw@mail.gmail.com>
References: <CAAjnpdjfMg+07bh+o0n1FTEZTp7dYm=6BTCTFD3MBRtfA0MvZw@mail.gmail.com>
Message-ID: <db1b67b0-d142-a5a8-30d3-52606229d0e5@gmail.com>

On 14/09/2018 3:22 AM, Witold E Wolski wrote:
> Dear Community,
> 
> I have an Rmarkdown vignette with optional child documents.
> Since all markdown files in the vingette folder are build when
> executing R CMD build
> I did place the child documents in
> /inst/ParametrizedReportChid/
> so they are excluded from the build.
> 
> I do reference them from the markdown file in the vignette folder by:
> 
> ```{r referencingChildDocument}
> child_docs <- "Grp2Analysis_MissingInOneCondtion.Rmd"
> if(!sum(NAinfo$nrProteins > 0) > 0){
>    child_docs <- "Grp2Analysis_Empty.Rmd"
> }
> child_docs <- system.file("ParametrizedReportsChild",child_docs,package
> = "SRMService")
> ```
> 
> ```{r includeMissingInOne, child = child_docs}
> ```
> 
> When running
> devtools::clean_vignettes()
> devtools::build_vingettes()
> devtools::build() # or R CMD build PACKAGE
> 
> all works fine. However,
> 
> devtools::clean_vignettes()
> devtools::build() # or R CMD build PACKAGE
> 
> Fails with the diagnostic:
> 
> ** building package indices
> ** installing vignettes
>     ?Grp2Analysis.Rmd? using ?UTF-8?
> Error in eval(x, envir = envir) : object 'child_docs' not found

This message makes it look as though it is looking for an R object named 
child_docs and not finding it.

> Warning in readLines(if (is.character(input2)) { :
>    cannot open file './child_docs': No such file or directory

This message makes it look as though it thinks "child_docs" is the 
filename, not a variable holding the filename.

> Quitting from lines 387-388 (./child_docs)

This one looks like it's a filename again.


It's a long vignette, and not easy to spot where things are going wrong. 
  I'd recommend backing up the original, and just cutting things out 
until the only thing left is the error.  Hopefully then it will be clear 
what's wrong.

Duncan Murdoch

> Error in readLines(if (is.character(input2)) { :
>    cannot open the connection
> ERROR: installing vignettes failed
> 
> I did try to use the base::system.file and devtools::system.file
> function but both generate the same error.
> 
> The package and vignette can be found here:
> https://github.com/protviz/SRMService



[Rd] Problem building rmarkdown vignettes with child
Duncan Murdoch