What is the proper way to append col names to the header of csv table which is generated by write.table
command?
For example write.table(x, file, col.names= c("ABC","ERF"))
throws error saying invalid col.names specification
.Is there way to get around the error, while maintaining the function header of write.table
.
Edit:
I am in the middle of writing large code, so exact data replication is not possible - however, this is what I have done:
write.table(paste("A","B"), file="AB.csv", col.names=c("A1","B1"))
, I am still getting this error Error in write.table(paste("A","B"), file="AB.csv", col.names=c("A", : invalid 'col.names' specification.
paste("A", "B")
returns a single string/column, and you specify two column names. Hence, the error. – Rich Scriven