I'm trying to write the output of cat into a file in R like this:
write(cat(as.character(i),"\n"),file="output.txt",append=TRUE)
However, it is not writing anything.
Note- cat(as.character(i),"\n" has a non-null output.
What am I missing or doing wrong here?
Why are you using cat inside write?
write is a wrapper for cat, so you could use either write or cat for this, but not both:
write(as.character(i), file = "output.txt", append = TRUE)
or
cat(as.character(i), sep = "\n", file = "output.txt", append = TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With