Last active
February 12, 2020 03:37
-
-
Save neetsdkasu/b3b842824ae8b9035f2c to your computer and use it in GitHub Desktop.
R言語 標準入力からEOFまでの全行読み込み
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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