Escribir líneas de texto en un archivo en R
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"?
Aceptado
fileConn<-file("output.txt")
writeLines(c("Hello","World"), fileConn)
close(fileConn)
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