我目前正在帮助一位教授为他在哈佛的课程Gov 50编写一本数据科学书籍。使用bookdown
程序包时遇到的问题是,我们似乎无法使用knit
按钮构建单独的章节并无法在新窗口中自动预览该章节。
我们得到的错误是:
Error in files2[[format]] :
attempt to select less than one element in get1index
Calls: <Anonymous> ... render_book -> setdiff -> as.vector -> source_files
Execution halted
因此,我们被迫使用preview_chapter()
功能,然后手动浏览该书的每个html文件,以查找要预览的章节。这最终很耗时,并且使我们的各个章节编写者都难以进行该过程。有谁知道是什么原因造成的?
我们的_output.yml文件似乎已正确设置:
bookdown::tufte_html_book:
df_print: default
css: style.css
split_by: "section"
config:
toc:
collapse: subsection
scroll_highlight: true
我已找到导致错误的原因!这是由我们索引中的yaml选项引起的。
--- site: bookdown::bookdown_site ---
删除此错误已解决编织错误。