Description Usage Arguments Details Value Examples
Open an R connection object for reading or writing to process
1 2 3 4 5 6 | pstream_input_con(stream, timeout = 5, stderr = FALSE)
pstream_output_con(stream, send_eof = FALSE)
## S4 method for signature 'pstream_output_con'
flush(con)
|
stream |
a pstream object |
stderr |
read from stderr? |
send_eof |
write EOF after sending message? |
con |
a pstream connection object |
R's connections
objects provide uniform access to a variety
of IO modes. These function build textConnection
object that
read or write to a pstream. An input connection simply reads from stdout,
or optionally stderr, and then returns that text when the connection is
read. Note that the reading happens at the time of creation.
You must call flush
on an output connection or nothing
will get written to the processes standard input. Because these objects
are textConnection
s, they cannot be used repeatedly.
Always initialize a new connection for each use.
a textConnection
object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | x = pstream("R", "--vanilla --slave")
c1 = pstream_output_con(x)
writeLines("R.Version()[[1]]", c1)
flush(c1) # required
c2 = pstream_input_con(x)
cat(readLines(c2))
pstream_close(x)
x = pstream("R", "--vanilla --slave")
a = 1:3
x %<<% "a = unserialize(stdin())"
c1 = pstream_output_con(x)
serialize(a, c1)
flush(c1) # required
x %<<% "serialize(a, stdout())"
c2 = pstream_input_con(x)
cat(unserialize(c2))
pstream_close(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.