How to read input from the terminal using /dev/stdin and read.csv()?

后端 未结 1 857
北恋
北恋 2021-01-23 02:30

I\'m using:

R version 3.0.0 (2013-04-03) -- \"Masked Marvel\"
Platform: x86_64-pc-linux-gnu (64-bit)

I try to use read.csv to inpu

相关标签:
1条回答
  • 2021-01-23 03:29

    I think the answer in the first link you posted may actually be applicable. R appears to create a 4 byte buffer on /dev/stdin. Also, as mentioned in the comment, you can use stdin instead, and it appears to work fine. (Although I still don't get why you have to hit Ctrl+D twice).

    d <- read.csv(file='stdin', header=TRUE)
    a,b
    1,2
    3,4
    # Hit Control+D twice.
    > d
      a b
    1 1 2
    2 3 4
    
    0 讨论(0)
提交回复
热议问题