windows 开始 R: 错误: '\U' 在以 ""C:\U" 开头的字符串中没有十六进制数字的情况下使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44273571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:53:18  来源:igfitidea点击:

starting R: Error: '\U' used without hex digits in character string starting ""C:\U"

rwindowsknitrtex

提问by antwalth

I have the following problem when starting RStudio and when I try to compile a PDF from a .rnw format:

启动 RStudio 以及尝试从 .rnw 格式编译 PDF 时,我遇到以下问题:

Error: '\U' used without hex digits in character string starting ""C:\U"

When starting RStudio or just R this is what is inside my console:

启动 RStudio 或只是 R 时,这是我的控制台中的内容:

R version 3.4.0 (2017-04-21) -- "You Stupid Darkness"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Global .Rprofile loaded!

Error: '\U' used without hex digits in character string starting ""C:\U"

And this happens when I try to compile a PDF:

当我尝试编译 PDF 时会发生这种情况:

Global .Rprofile loaded!

Error: '\U' used without hex digits in character string starting ""C:\U"
Execution halted

This kind of appeared from one day to another and I am not sure what has changed. I tried updating RStudio and my R-version, but it did not help. I am running R on Windows.

这种情况一天一天出现,我不确定发生了什么变化。我尝试更新 RStudio 和我的 R 版本,但没有帮助。我在 Windows 上运行 R。

Can anybody help me with that issue?

有人可以帮我解决这个问题吗?

回答by antwalth

I was able to solve this after all:

毕竟我能够解决这个问题:

I had a section inside my .Rprofile file (in Documents) with "\" instead of "/". So I now changed

我的 .Rprofile 文件(在文档中)中有一个部分用“\”代替“/”。所以我现在改变了

# Set mainfolder for PACKAGE package
options(PACKAGE_MAINFOLDER="C:\Users\...")

to

# Set mainfolder for PACKAGE package
options(PACKAGE_MAINFOLDER="C:/Users/...")

and that did the trick.

这就是诀窍。

回答by Edmar Campos Cardoso

To make it work, just remove the C:\Users\edmar.campos.cardoso\Dropbox\and replace all \with /using the function setwd()to change the working directory in R.

为了使它的工作,只是删除C:\Users\edmar.campos.cardoso\Dropbox\和替换所有\/使用功能setwd()改变工作目录R

Wrong way:

错误的方法:

setwd('C:\Users\edmar.campos.cardoso\Dropbox\...')

Right way:

正确的方法:

setwd('/Users/edmar.campos.cardoso/Dropbox/...')

回答by Abhijit

For importing files in R, replace the '\' with (two) '\'. Single '\' probably reads it as escape sequence and hence the file path error.

要在 R 中导入文件,请将“\”替换为(两个)“\”。单个 '\' 可能将其读取为转义序列,因此文件路径错误。

回答by aghd

You can use \\instead of \. This allows skipping from some characters such as \nwhich is the end of the line or \twhich is tab.

您可以使用\\代替\. 这允许跳过某些字符,例如\n哪个是行尾或\t哪个是制表符。

回答by Mohammad Yassier Bashier

Open the CSV file and Save as the file to your MYDocuments. Then use this

打开 CSV 文件并将该文件另存为您的 MYDocuments。然后用这个

[MyData <- read.csv("Data.csv",header = TRUE)]

if its text just change read.csv to read.text

如果它的文本只是将 read.csv 更改为 read.text