readLines(con = stdin(), n = -1L, ok = TRUE, warn = TRUE, encoding = "unknown", skipNul = FALSE)writeLines(text, con = stdout(), sep = "\n", useBytes = FALSE)
con | a connection. By default, the standard input for readLines and standard output for writeLines. |
n | an integer. The number of lines to read. The default -1L indicates readLines should read to the end of the file. |
ok | a logical value. If FALSE, and readLines reaches the end of the file before n lines are read, an error is generated. If TRUE (the default), no error is produced. |
warn | This argument is not yet implemented. a logical value. If flush=TRUE, this generates a warning if the final line read does not include a terminating new-line character. |
encoding | This argument is not yet implemented. the string encoding to use for newly-created strings. (See Encoding.) |
text | the character vector to write. Each element is written as one line. |
sep | a character string. The separator between lines. The default is "\n". |
useBytes | In Spotfire Enterprise Runtime for R, this argument is ignored. All strings are written using the encoding of the output connection. |
skipNul |
A logical value specifying how to deal with nul (0) bytes in the input file.
|
readLines | returns the lines of input (with no new-line characters) as elements of a character vector. |
writeLines | returns invisible(NULL). |
tfile <- tempfile() writeLines(paste(Sdatasets::state.abb, Sdatasets::state.name, sep=": ")[1:10], con=tfile) readLines(tfile) readLines(tfile, n=3)conn <- file(tfile, "rt") readLines(conn, n=2) # first 2 lines readLines(conn, n=2) # next 2 lines close(conn) unlink(tfile)