Bookdown构建报错:控制台可运行代码但提示对象/函数未找到
问题概述
我正在用bookdown构建一本包含以下代码的书籍:
ggdotchart(themes, x = "theme", y = "citations", # requires `easyGgplot2`, `ggplot2`, `ggpubr` color = "#440154", # Color by groups palette = c("#00AFBB", "#E7B800", "#FC4E07"), # Custom color palette sorting = "descending", # Sort value in descending order add = "segments", # Add segments from y = 0 to dots rotate = TRUE, # Rotate vertically dot.size = 9, # Large dot size label = round(themes$citations), # Add citations values as dot labels font.label = list(color = "white", size = 10, vjust = 0.5), # Adjust label parameters ggtheme = theme_pubr(), # ggplot2 theme ylab="Citation Count", xlab="Theme" )
这段代码在R控制台中运行可正常生成图表,图表样式为:横向排列的主题作为x轴,y轴为引用次数,每个主题对应一个大尺寸深色圆点,圆点内带有白色引用次数数值标签,每个圆点下方有从y=0延伸的线段,整体使用pubr主题样式。
但执行knit操作时出现以下报错:
Quitting from lines 28-42 (bookdown-demo.Rmd) Error in ggdotchart(themes, x = "theme", y = "citations", color = "#440154", : could not find function "ggdotchart" Calls: <Anonymous> ... withVisible -> eval_with_user_handlers -> eval -> eval In addition: Warning message: In xfun::prose_index(x) : Code fences are not balanced Execution halted
执行bookdown构建操作时则出现以下报错:
Quitting from lines 54-68 (bookdown-demo.Rmd) Error in ggdotchart(themes, x = "theme", y = "citations", color = "#440154", : object 'themes' not found Calls: local ... eval_with_user_handlers -> eval -> eval -> ggdotchart Execution halted Error: bookdown::render_book() failed to render the output format 'bookdown::gitbook'. Execution halted Exited with status 1.
已尝试的操作
- 对数据列进行类型转换:
themes$citations <- as.character(themes$citations) - 加载数据文件:
load("themes.RData")
环境信息
- 项目基于bookdown官方演示模板的全新副本搭建
内容的提问来源于stack exchange,提问作者cmadland
相关产品推荐
相关产品推荐

