set separator ';' in write.csv

dsent picture dsent · Jun 23, 2016 · Viewed 34.3k times · Source

I have the following code:

myTable[i,] = strsplit(line, split=";")[[1]]
write.csv(myTable[-1,], file="episodes_cleared.csv", sep=";", row.names=FALSE, quote=FALSE)

Unfortunately, the separator still is ',':

iEpisodeId,iPatientId,sTitle,sICPc,dStart,dEnd,bProblem

Running the code gives me:

Warning messages:

1: In write.csv(myTable[-1, ], file = "episodes_cleared.csv", sep = ";",  : attempt to set 'sep' ignored
2: In write.csv(myTable[-1, ], file = "episodes_cleared.csv", sep = ";",  :

attempt to set 'sep' ignored

What am I doing wrong?

Answer

Michael Kirchner picture Michael Kirchner · Jun 23, 2016

First, you should provide a reproducible example.

However, if you use write.csv2 it defaults to using a semicolon as the separator.