[R] write.table with append=T after using cat on same file
Waichler, Scott R
Scott.Waichler at pnnl.gov
Mon Jul 27 22:32:18 CEST 2015
Hi,
For years I've been writing text to the beginning of files with cat(append=F) , then following that text with data written by write.table(append=T). It is now giving me an error message. I'm using R-3.1.2. What gives?
df <- data.frame(x = 1, y = 1:10, z = 10:1)
cat(file="junk.txt", sep="", "# An introductory note.\n")
write.table(df, file="junk.txt", sep=",", append=T, quote=F, row.names=F, col.names=F)
Error in file(file, ifelse(append, "a", "w")) : invalid 'open' argument
Thanks,
Scott Waichler
Pacific Northwest National Laboratory
Richland, WA USA
More information about the R-help
mailing list