在用rmarkdown文件生成html文件时出错,相关出错信息如下,请问怎么解决这个问题。
pandoc.exe: Cannot decode byte '\xa9': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream
Error: pandoc document conversion failed with error 1
Execution halted
我的Rstudio版本为RStudio 2023.06.2+561,rmarkdown文件保存的编码为utf-8。我的系统环境如下:
> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 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] patchwork_1.1.2 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2
[6] purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2
[11] tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] utf8_1.2.3 generics_0.1.3 stringi_1.7.12 lattice_0.21-8 hms_1.1.3
[6] digest_0.6.31 magrittr_2.0.3 evaluate_0.21 grid_4.3.0 timechange_0.2.0
[11] fastmap_1.1.1 cellranger_1.1.0 Matrix_1.5-4.1 writexl_1.4.2 mgcv_1.8-42
[16] fansi_1.0.4 scales_1.2.1 cli_3.6.0 rlang_1.1.1 munsell_0.5.0
[21] splines_4.3.0 withr_2.5.0 yaml_2.3.7 tools_4.3.0 tzdb_0.4.0
[26] colorspace_2.1-0 vctrs_0.6.2 R6_2.5.1 lifecycle_1.0.3 pkgconfig_2.0.3
[31] pillar_1.9.0 gtable_0.3.3 glue_1.6.2 xfun_0.39 tidyselect_1.2.0
[36] rstudioapi_0.14 knitr_1.44 farver_2.1.1 htmltools_0.5.5 nlme_3.1-162
[41] rmarkdown_2.25 labeling_0.4.2 compiler_4.3.0 readxl_1.4.2
rmd内容如下:
---
title: "Untitled"
author: "yongchuang"
date: "2023-09-21"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
Including Plots
You can also embed plots, for example:
plot(pressure)
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.