I am trying to write an array to a CSV without the row and column names. Setting the column names to false doesnt seem to work. I get "x" for the column name and a warning.
Any ideas how to remove this "x"?
write.csv(1:5, row.names = F, col.names = F)
# "x"
# 1
# 2
# 3
# 4
# 5
# Warning message:
# In write.csv(1:5, row.names = F, col.names = F) :
# attempt to set 'col.names' ignored
?write.csv
tells us that among other things, for the arguments to write.csv:
append, col.names, sep, dec and qmethod cannot be altered
The way to get round this is to use the more general version, write.table.
write.table(1:5, row.names = FALSE, col.names = FALSE, sep=',')
# 1
# 2
# 3
# 4
# 5
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