Learn R Programming

ctypesio (version 0.1.2)

fprintf: Print formatted strings to a connection

Description

fprintf_raw() writes the text without a nul-terminator. fprintf() writes a nul-terminator

Usage

fprintf(con, fmt, ..., sep = "\n", useBytes = FALSE)

fprintf_raw(con, fmt, ..., sep = "\n", useBytes = FALSE)

Value

If con is a connection then this connection is returned invisibly. If con is a raw vector then new data is appended to this vector

Arguments

con

Connection object or raw vector. When con is a raw vector, new data will be appended to the vector and returned. Connection objects can be created with file(), url(), rawConnection() or any of the other many connection creation functions.

fmt

a character vector of format strings. See sprintf()

...

values to be passed in to fmt. See sprintf()

sep

If there are multiple strings to be printed, this separated will be written after each one.

useBytes

See writeLines()

See Also

Other data output functions: write_f64(), write_hex(), write_raw(), write_uint8(), write_utf8()

Examples

Run this code
con <- rawConnection(raw(), "wb")
fprintf(con, "%i,%6.2f", 1, 3.14159)
close(con)

Run the code above in your browser using DataLab