When working in RStudio you need to use readLines(stdin())
, not readLines(file('stdin'))
, although you can use either when you start R in the terminal.
, , RStudio. stdin, Ctrl + D . , RStudio, Ctrl + D , stdin.
, R , , Ctrl + D. RStudio, readLines(stdin())
; .
> readLines(stdin(), n=2)
Hello
World
[1] "Hello" "World"
scan()
, :
> scan(,'')
1: Hello
2: World
3:
Read 2 items
[1] "Hello" "World"
( Enter ). , .