How to call a script that uses scan () on Windows?

How to invoke an R script as shown below

scan()

on windows? When using Ror Rscriptnothing is read. With Rscriptor littler(as on Linux) the script works as expected.

# Doesn't work because stdin is already redirected
R --no-save < test.R

# Works on Linux, doesn't on Windows
Rscript test.R

# Works on Linux, doesn't exist in Windows
r test.R

Is it even possible to achieve this without changing the R code?

Perhaps it is connected: why in Windows there is no switch --interactive?

+2
source share
1 answer

So, as we discussed in the comments and with @nograpes confirmation, you can use the following:

scan(file("stdin"), what=character())

script scan() , script .
Ctrl + Z, Windows (Ctrl + D Mac).

+5

Source: https://habr.com/ru/post/1622163/


All Articles