I am working in R and am supposed to split the stdin
inputs using space
and newline
characters. However, when I take the input as a string from stdin using the following code:
f <- file("stdin")
open(f)
sampleInput <- readLines(f)
with the following values in stdin
:
1 2
3 4 4
print(sampleInput)
returns the following output and I am not sure how to split it.
[1] "1 2" "3 4 4"
Can someone suggest a way to split this input using space and newline characters (just like split()
works in python) as follows?
[1] "1" "2" "3" "4" "4"