Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bookdown not building - replacement length zero

Tags:

r

bookdown

I'm getting the following error when trying to build this gitbook on my local machine (was trying to use it as a template for creating my own work):

https://github.com/lgatto/IntroMachineLearningWithR

Error:

Error in x[i] <- sprintf("<a href=\"%s#%s\"", filenames[which.max(lines[lines <= : replacement has length zero

Calls: <Anonymous> ... <Anonymous> -> split_chapters -> restore_links -> lapply -> FUN

Also the warning below comes up, but this is probably less mission critical to fix:

In addition: Warning message: In split_chapters(output, gitbook_page, number_sections, split_by, : You have 6 Rmd input file(s) but only 5 first-level heading(s). Did you forget first-level headings in certain Rmd files?

Session info:

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.5.1  backports_1.1.2 bookdown_0.7    rsconnect_0.8.8 rprojroot_1.3-2 htmltools_0.3.6
 [7] tools_3.5.1     yaml_2.2.0      Rcpp_0.12.19    rmarkdown_1.10  knitr_1.20      xfun_0.4       
[13] digest_0.6.18   evaluate_0.12  
like image 606
dvanic Avatar asked Nov 07 '18 00:11

dvanic


1 Answers

I'm very late to the game on this one, but make sure the first-level heading in the .rmd file you're knitting is #, and not ## or ### and so on. I was having the same error, and this resolved it for me.

like image 108
Sean Hardison Avatar answered Oct 29 '22 04:10

Sean Hardison