错误:在以“C:\R"开头的字符串中,“\R"是无法识别的转义符; [英] Error: '\R' is an unrecognized escape in character string starting "C:\R"

查看:82
本文介绍了错误:在以“C:\R"开头的字符串中,“\R"是无法识别的转义符;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的是 Windows XP Pro 并且 R 版本 2.15.1 R 安装在以下文件夹中:

I am running Windows XP Pro and R Version 2.15.1 R is installed in the following folder:

C:\Program Files\R\R-2.15.1

C:\Program Files\R\R-2.15.1

我正在尝试创建一个读取 .csv 文件的函数,如下所示:

I am trying to create a function that reads in a .csv file like so:

xxx <- function(id, directory, summarize = FALSE) {
    data <- read.table('C:\xxx\classes\R_Prog\specdata\data.csv')
    head(data)
}

我收到错误

错误:'\R' 是字符串中以C:\R"开头的无法识别的转义

Error: '\R' is an unrecognized escape in character string starting "C:\R"

我的目录结构/文件夹命名约定有问题吗?

Is there a problem with my directory structure / folder naming conventions?

推荐答案

你必须对 \ 进行转义,因为它本身就是一个转义字符.

You have to escape the \ since it is itself an escape character.

read.table('C:\\xxx\\classes\\R_Prog\\specdata\\data.csv') head(data) }

这篇关于错误:在以“C:\R"开头的字符串中,“\R"是无法识别的转义符;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆