user3453816
user3453816

Reputation: 17

Adding comma between two numbers

I have a data as below.

 0.0  5.0
 1.0  5.1
 2.0 13.3
 3.0 29.5
 4.0 44.4
 5.0 54.6
 6.0 63.5
 7.0 69.1
 8.0 73.9
 9.0 72.4
10.0 72.3
11.0 76.1
12.0 74.3
13.0 77.8
14.0 78.1
15.0 79.5
16.0 80.5
17.0 79.8
18.0 78.1
19.0 77.0
20.0 78.9

and I would like to add comma between two numbers such as

 0.0,  5.0
 1.0,  5.1
 2.0, 13.3
 3.0, 29.5
 4.0, 44.4
 5.0, 54.6
 6.0, 63.5
 7.0, 69.1
 8.0, 73.9
 9.0, 72.4
10.0, 72.3
11.0, 76.1
12.0, 74.3
13.0, 77.8
14.0, 78.1
15.0, 79.5
16.0, 80.5
17.0, 79.8
18.0, 78.1
19.0, 77.0
20.0, 78.9

Do you have any idea how to add a comma between two numbers? thanks

Upvotes: 0

Views: 709

Answers (1)

Rich Scriven
Rich Scriven

Reputation: 99331

Assuming d is the data, you can use write.table with sep = ", ". Here are a few lines:

> write.table(d, row.names = FALSE, col.names = FALSE, sep = ", ")
0, 5
1, 5.1
2, 13.3
3, 29.5
4, 44.4
5, 54.6
6, 63.5
7, 69.1

Upvotes: 4

Related Questions