RStudio是否在保存时编辑脚本?

时间:2019-09-11 12:32:33

标签: r rstudio

我正在用R读取pdf文件。在分析它们之前,我先执行清洁过程。

更具体地说,我正在使用此自定义功能:

cleanFile = function(x) {
    x = str_replace_all(string = x, pattern = "\\s+", replacement = " ") # not interesting for this post
    x = str_replace_all(string = x, pattern = "–", replacement = "-")
}

第二行用“正常”连字符"-"替换了我的pdf文件中包含的,看起来像连字符的特殊字符。

下面是一些代码:

pdfClean = lapply(pdfList, cleanFile) # files cleansed
str_detect(pdfClean[[1]], "–") # checking if the special character appears - this last bit is not part of the script, I type it in the console so it's not affected by save.

当我保存并运行脚本时,最后一行意外返回TRUE。 我知道"–"字符已被替换为其他字符,因为如果我将其替换回代码中并在不保存的情况下运行相同的脚本,则最后一行将按预期返回FALSE

此外,此问题仅在我更换计算机后才出现。过去,我使用的是其他代码,并且我的代码运行时没有任何问题。

我尝试使用工具->全局选项->代码->保存->默认文本编码进行了一些实验,但是我没有解决任何问题。

任何帮助将不胜感激。

0 个答案:

没有答案