Powershell 中此 Rscript 命令没有标准输出

时间:2021-06-10 16:45:09

标签: r powershell rscript

我正在尝试在 Windows 中编写与此 Bash 命令等效的命令:

(tee <<"EOF"
<some-markdown-and-html>
EOF
) | Rscript -e '
input <- file("stdin", "r")
content <- readLines(input)
print(content)
'

我对 Windows 非常不熟悉,并认为 Powershell 似乎是一个不错的选择,但是我在将文本输出到 stdout 时遇到了一个奇怪的问题。此命令有效:

(@" 
<some-markdown-and-html>
"@) | Rscript -e @"
print(readLines(file('stdin', 'r')))
"@

具有所需的输出:

[1] "<some-markdown-and-html>"

然而,当我将 R 脚本分成多行时,它什么都不输出:

(@" 
<some-markdown-and-html>
"@) | Rscript -e @"
input <- file('stdin', 'r')
content <- readLines(input)
print(content)
"@ 

如何使用多行 R 脚本打印到标准输出?不需要是 Powershell,只需兼容 Windows(理想情况下不安装 WSL)。谢谢

0 个答案:

没有答案
相关问题