【问题标题】:pass character "&" by args to R通过 args 将字符“&”传递给 R
【发布时间】:2015-12-21 09:19:00
【问题描述】:

以下 R 代码将通过命令提示符(windows)执行

# Collect arguments
args <- commandArgs(TRUE)

archivo <- as.character(args[1])

cat(archivo)

喜欢这个

C:\Users\Owner\Desktop>Rscript prueba.r "hola&chao"

问题是命令提示符响应

hola
'chao' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Owner\Desktop>

我需要 R 接受“&”作为字符并在 cat() 中一起打印

我该怎么办? 谢谢

【问题讨论】:

    标签: r args rscript


    【解决方案1】:

    这不是 R 问题,而是 shell 问题。你真的执行了

    Rscript prueba.r hola&chao
    

    而不是

    Rscript prueba.r "hola&chao"
    

    在 Windows 命令外壳中,

    prog1 & prog2
    

    按顺序执行两个程序,这就是为什么您会看到

    的输出
    Rscript prueba.r hola
    

    接着是输出

    chao
    

    另一种可能性是Rscript 是一个有问题的批处理文件。

    猜你喜欢
    • 2016-01-27
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 1970-01-01
    • 1970-01-01
    • 2015-02-12
    • 2013-09-01
    • 1970-01-01
    相关资源
    最近更新 更多