You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

R Markdown中ggplot内嵌预览乱码,无法生成reprex求助

问题:安装easystats并更新ggplot2后R Markdown预览乱码及reprex生成失败

安装easystats包并更新ggplot2后,R Markdown中ggplot绘图的内嵌预览消息出现奇怪符号,且该问题导致无法生成reprex,所有R Markdown的ggplot预览均受影响。

测试代码

---
title: "Test"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reprex)
library(tidyverse)
mtcars %>% 
  ggplot(aes(x = mpg)) + 
  geom_histogram()
## 生成reprex时的报错信息
```r
Error in parse(text = x, keep.source = TRUE) : 
<text>:5:3: unexpected symbol
4: 
5: R version
^

推测该报错由乱码导致,若屏蔽消息则无法生成能复现问题的reprex,以下是会话信息:

会话信息

R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] reprex_2.0.1    forcats_0.5.1   stringr_1.4.0   dplyr_1.0.10    purrr_0.3.4     readr_2.1.1    
 [7] tidyr_1.2.1     tibble_3.1.8    ggplot2_3.4.2   tidyverse_1.3.1

loaded via a namespace (and not attached):
 [1] httr_1.4.2         jsonlite_1.7.2     viridisLite_0.4.0  R.utils_2.12.2     modelr_0.1.8      
 [6] assertthat_0.2.1   cellranger_1.1.0   yaml_2.2.1         gdtools_0.2.3      pillar_1.7.0      
[11] backports_1.4.1    glue_1.6.2         uuid_1.0-3         digest_0.6.29      rvest_1.0.2       
[16] colorspace_2.0-2   R.oo_1.25.0        htmltools_0.5.2    clipr_0.7.1        pkgconfig_2.0.3   
[21] broom_0.7.10       haven_2.4.3        scales_1.2.1       officer_0.4.1      tzdb_0.2.0        
[26] proxy_0.4-26       styler_1.9.1       farver_2.1.0       generics_0.1.3     ellipsis_0.3.2    
[31] withr_2.5.0        lazyeval_0.2.2     cli_3.4.1          magrittr_2.0.1     crayon_1.5.0      
[36] readxl_1.3.1       evaluate_0.14      R.methodsS3_1.8.2  fs_1.5.2           fansi_0.5.0       
[41] R.cache_0.16.0     xml2_1.3.3         class_7.3-20       rsconnect_0.8.25   tools_4.1.3       
[46] data.table_1.14.2  hms_1.1.1          lifecycle_1.0.3    plotly_4.10.0      flextable_0.6.10  
[51] munsell_0.5.0      zip_2.2.0          compiler_4.1.3     e1071_1.7-9        systemfonts_1.0.3 
[56] rlang_1.1.0        classInt_0.4-3     units_0.7-2        grid_4.1.3         rstudioapi_0.13   
[61] htmlwidgets_1.5.4  labeling_0.4.2     base64enc_0.1-3    rmarkdown_2.21     gtable_0.3.0      
[66] DBI_1.1.2          R6_2.5.1           lubridate_1.8.0    knitr_1.37         fastmap_1.1.0     
[71] utf8_1.2.3         KernSmooth_2.23-20 stringi_1.7.6      Rcpp_1.0.7         vctrs_0.5.0       
[76] sf_1.0-5           dbplyr_2.1.1       tidyselect_1.2.0   xfun_0.38         

恳请协助解决该问题!

内容的提问来源于stack exchange,提问作者Sentient_Slime_Mold

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 01:20:44