Escribir líneas de texto en un archivo en R

Resuelto amarillion asked hace 54 años • 13 respuestas

En el lenguaje de programación R, ¿cómo escribo líneas de texto, por ejemplo, las dos líneas siguientes?

Hello
World

a un archivo llamado "output.txt"?

amarillion avatar Jan 01 '70 08:01 amarillion
Aceptado
fileConn<-file("output.txt")
writeLines(c("Hello","World"), fileConn)
close(fileConn)
Mark avatar Mar 18 '2010 13:03 Mark

En realidad puedes hacerlo con sink():

sink("outfile.txt")
cat("hello")
cat("\n")
cat("world")
sink()

por lo tanto haz:

file.show("outfile.txt")
# hello
# world
aL3xa avatar Mar 18 '2010 16:03 aL3xa