使用Powershell在Rscript.exe表达式中双引号

问题描述 投票:0回答:1

在使用Powershell中的“-e”标志将表达式发送到Rscript.exe时,我似乎无法正确地将双引号传递给R.

当我从?Rscript文档中尝试标准Windows命令行的命令时:

& 'C:\Program Files\R\R-3.5.2\bin\Rscript.exe' -e "date()" -e "format(Sys.time(), \"%a %b %d %X %Y\")"

它返回:

[1] "Thu Jan 31 20:27:53 2019"
Error: unexpected end of input
Execution halted

从我如何理解Powershell字符串,我希望这可以工作:

& 'C:\Program Files\R\R-3.5.2\bin\Rscript.exe' -e 'date()' -e 'format(Sys.time(), "%a %b %d %X %Y")'

但它返回:

[1] "Thu Jan 31 20:36:02 2019"
Error: unexpected input in "format(Sys.time(), %a"
Execution halted

有谁知道我应该如何格式化这些命令?谢谢!

r
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.