【问题标题】:Why is R not scanning the data为什么R不扫描数据
【发布时间】:2020-07-24 20:14:32
【问题描述】:

我尝试在 R 中扫描数据。 我的代码:

scan("D:\\Projekt1\\Lauf.dat",sep=",")

我的数据内容:

10.2、11.4、10.5、9.8、9.9、9.9、10.3、10.8、10.2、11.5、 10.0、11.4、11.2、10.1、10.5、12.0、11.4、10.2、10.1、12.1

预期输出:

[1] 10.2 11.4 10.5 9.8 9.9 9.9 10.3 10.8 10.2 11.5 10.0 11.4 11.2 10.1 10.5

[16] 12.0 11.4 10.2 10.1 12.1

但是我收到了这个错误:

文件中的警告(文件,“r”):无法打开文件'':参数无效

文件中的错误(文件,“r”)(main.R#1):无法打开连接显示 堆栈跟踪

我做错了什么?我希望你能帮助我。

BR 马可

【问题讨论】:

    标签: r


    【解决方案1】:

    尝试用以下代码替换您的代码:

    setwd("D:\\Projekt1") 
    scan("Lauf.dat",sep=",")
    

    edit-1:

    setwd("D:/Projekt1") #used forward slash

    【讨论】:

    • 使用代码:setwd("‪D:\\Projekt1") 我收到此错误:(main.R#1): cannot change working directory Show stack trace
    • 为什么你的路径中有`\\`?
    • 在 R 中,您必须使用 ´\\` 编写路径。如果我尝试用 ´\` 编写它,我会收到此错误:`Error: '\P' is an unrecognized escape in character string started ""D:\P"´
    • 完美!谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    • 1970-01-01
    相关资源
    最近更新 更多