“writeLines()”
method is used to write data to a file/connection.
Synatx
writeLines(text,
con = stdout(), sep = "\n", useBytes = FALSE)
Parameter
|
Description
|
text
|
Represents
a character vector, each member of a vector stored as separate line in a
file.
|
con
|
A
connection object to a file
|
sep
|
A string
to be written after writing each line to a file
|
useBytes
|
It is a
Boolean variable. If it is set to FALSE, character strings with marked
encodings are converted to the current encoding before being passed to the
connection. if useBytes is set to TRUE, then it suppresses the re-encoding of
marked strings so they are passed byte-by-byte to the connection
|
> fileConn<-file("output.txt") > writeLines(c("first line","second line", "third line"), fileConn) > close(fileConn)
Run above
commands in R Console, it creates “output.txt” with following data.
first line
second line
third line
No comments:
Post a Comment