R ignora linhas de / dev / stdin

Eu tenho um arquivo com uma lista de números (faça por você mesmo:for x in $(seq 10000); do echo $x; done > file).

$> R -q -e "x <- read.csv('file', header=F); summary(x);"

> x <- read.csv('file', header=F); summary(x);
       V1       
 Min.   :    1  
 1st Qu.: 2501  
 Median : 5000  
 Mean   : 5000  
 3rd Qu.: 7500  
 Max.   :10000  
gt; R -q -e "x <- read.csv('file', header=F); summary(x);" > x <- read.csv('file', header=F); summary(x); V1 Min. : 1 1st Qu.: 2501 Median : 5000 Mean : 5000 3rd Qu.: 7500 Max. :10000

Agora, pode-se esperarcatlendo o arquivo e lendo/dev/stdin ter a mesma saída, mas não:

$> cat file | R -q -e "x <- read.csv('/dev/stdin', header=F); summary(x);"
> x <- read.csv('/dev/stdin', header=F); summary(x);
       V1       
 Min.   :    1  
 1st Qu.: 3281  
 Median : 5520  
 Mean   : 5520  
 3rd Qu.: 7760  
 Max.   :10000 
gt; cat file | R -q -e "x <- read.csv('/dev/stdin', header=F); summary(x);" > x <- read.csv('/dev/stdin', header=F); summary(x); V1 Min. : 1 1st Qu.: 3281 Median : 5520 Mean : 5520 3rd Qu.: 7760 Max. :10000

Usandotable(x) mostra que um monte de linhas foram ignoradas:

    1  1042  1043  1044  1045  1046  1047  1048  1049  1050  1051  1052  1053 
    1     1     1     1     1     1     1     1     1     1     1     1     1 
 1054  1055  1056  1057  1058  1059  1060  1061  1062  1063  1064  1065  1066 
    1     1     1     1     1     1     1     1     1     1     1     1     1
 ...

Parece que R está fazendo algo engraçado comstdin, como este Python irá imprimir corretamente todas as linhas no arquivo:

cat file | python -c 'with open("/dev/stdin") as f: print f.read()'

Essa questão parece relacionado, mas é mais sobre pular linhas em um arquivo CSV mal formado, enquanto minha entrada é apenas uma lista de números.

questionAnswers(1)

yourAnswerToTheQuestion