[R] Remove comma (,) in data set

Duncan Murdoch dmurdoch at pair.com
Tue Sep 30 19:09:40 CEST 2003


On Tue, 30 Sep 2003 18:51:52 +0200, Muhammad Subianto
<subianto at cs.uu.nl> wrote :

>Dear R-helper,
>I am new learning R. Now, I have a data set like:
>
>24,2,3,3,1,1,2,3,0,1
>45,1,3,10,1,1,3,4,0,1
>... with 3730 rows
>
>I want to remove comma (,) in data set. The result like:
>
>24 2 3  3 1 1 2 3 0 1
>45 1 3 10 1 1 3 4 0 1
>...
>How can I do it. Thanks you for your help.

I assume you're talking about reading a file with commas, and writing
one without.

Use one of the read functions (e.g. read.csv, read.table, or scan)
which can deal with the commas on input.  Then write using write.table
with the default separator, a space.

You'll likely want non-default choices for the row.names and col.names
parameters.

Duncan Murdoch




More information about the R-help mailing list