How to inject EOF in stdin in R?

I am new to R, I am wondering how to introduce EOF in stdin for R? For example, the readLines () function reads input lines from stdin, but how can this stop it?

Problem rookie and thanks for watching.

PS. The problem is solved. But I still can't inject EOF into StatET (R plugin for eclipse). Anyone have any solution?

+3
source share
1 answer

The input is processed by a library readlinecommon to other GNU project programs, and it usually gets EOF when you press Ctrl-D.

Here is an example of using littler (and I'm not sure why every inout gets an echo back):

$ r -e 'print(summary(as.integer(readLines())))'
1
1
2
2
3
3
4
4
8
8                                                    ## I pressed Ctrl-D here
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    1.0     2.0     3.0     3.6     4.0     8.0 
$ 
+2
source

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


All Articles