Skip to content

Instantly share code, notes, and snippets.

@neetsdkasu
Last active February 12, 2020 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neetsdkasu/b3b842824ae8b9035f2c to your computer and use it in GitHub Desktop.
Save neetsdkasu/b3b842824ae8b9035f2c to your computer and use it in GitHub Desktop.
R言語 標準入力からEOFまでの全行読み込み
# example 1
f <- file("stdin") # 標準入力
s <- readLines(f) # 全行読み込み
cat(s[1]) # 1行目を出力
# example 2
s <- readLines("stdin") # 直接指定してもOK
cat(s, sep="\n") # 配列 s の全ての要素を"\n"(改行文字)区切りで出力
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment