Hi guys, when I compiled a bs4_book, I got an error, here is the traceback:
Error in 1:max_n : 答案矢量会太长
15. paste(words[1:max_n], collapse = " ")
14. tweak_metadata(html, path)
13. bs4_chapter_tweak(path, toc, rmd_index = rmd_index, repo = repo,
footnotes_inline = footnotes_inline)
12. bs4_chapters_tweak(output, repo = repo, rmd_index = unlist(as.list(rmd_index)),
output_dir = output_dir, footnotes_inline = footnotes_inline)
11. bs4_book_build(output, repo = repo, lib_dir = lib_dir, split_bib = split_bib,
footnotes_inline = footnotes_inline)
10. output_format$post_processor(front_matter, input, output_file,
clean, !quiet)
9. rmarkdown::render(main, output_format, ..., clean = clean, envir = envir,
run_pandoc = TRUE, knit_meta = knit_meta)
8..render_new_session(files, main, config, output_format, clean,
envir, ...)
7. render_book(index, output_format = output_format, envir = envir)
6. render_book_script(output_format, envir, quiet)
5. in_dir(input, render_book_script(output_format, envir, quiet))
4. siteGenerator$render(input_file = NULL, output_format = NULL,
envir = new.env(), quiet = quiet, encoding = getOption("encoding"))
3. site$render()
2. rsconnect::deploySite(siteDir = getwd(), siteName = name, account = account,
server = server, render = render, logLevel = "normal")
1. publish_book(name = "survival", render = "local")
This error occurs when I compile a new chapter, but it didn't happen before I try to add this new chapter. But I've checked the texts and codes of this chapter, I found no typos or omissions.
As I check the original code of bs4_book.R, I found three places about max_n
:
max_n <- max(which(no_char<= 197))
description_string <- paste(words[1: max_n], collapse = " ")
if (max_n != length(words)) {
description_string <- paste0(description_string, "...")
}
But I still don't know how to fix the error. Any solution? Thanks!
Here is my sessionInfo:
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8
[2] LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8
time zone: Asia/Shanghai
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] bookdown_0.38
loaded via a namespace (and not attached):
[1] vctrs_0.6.5 cli_3.6.2 knitr_1.45 rlang_1.1.3
[5] xfun_0.43 jsonlite_1.8.8 glue_1.7.0 htmltools_0.5.8
[9] sass_0.4.9 rsconnect_1.2.1 fansi_1.0.6 rmarkdown_2.26
[13] evaluate_0.23 jquerylib_0.1.4 tibble_3.2.1 fastmap_1.1.1
[17] yaml_2.3.8 lifecycle_1.0.4 memoise_2.0.1 compiler_4.3.2
[21] fs_1.6.3 pkgconfig_2.0.3 downlit_0.4.3 rstudioapi_0.16.0
[25] digest_0.6.34 R6_2.5.1 utf8_1.2.4 pillar_1.9.0
[29] magrittr_2.0.3 bslib_0.7.0 tools_4.3.2 withr_3.0.0
[33] xml2_1.3.6 cachem_1.0.8