KarthikS
KarthikS

Reputation: 903

How to set row.names=FALSE and na=" " by default for write.csv?

While I issue the write.csv(dataframe_name,"File_name.csv"), I add the parameters row.names=F and na=" " for ease of reading in MS-Excel. Is there a default option in R to always set these parameters.

Upvotes: 1

Views: 2099

Answers (2)

Sheila
Sheila

Reputation: 2597

You can also use the write.table function

write.table( dataframe_name, filename = "file.csv, sep=",", row.names=FALSE, ...)

That's worked for me at least.

Upvotes: 0

mnel
mnel

Reputation: 115515

You can easily write a function to mask this

write.csv <- function(...,row.names=FALSE,na = ' '){
   utils::write.csv(..., row.names = row.names, na = na)
}

and place this in your .Rprofile file [or build a simple package which exports this....]

Upvotes: 5

Related Questions