Produce the output with fixed column widths.
You want to paste in a format that can be cut and pasted into another tool. Fixed-width columns are easily readable by both human and machine, so that is a good format to use.
In comparison, comma-separated is easily machine-readable, but not so good for humans.
R prints in fixed-column-width by default to the screen, which makes cut and paste quite convenient. For example:
> head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
Here, >
is the prompt character, and I entered the command head(iris)
to print that part of this table. Printing this with write.csv
to get a CSV equivalent results in this output, which is not human-friendly:
"","Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","Species"
"1",5.1,3.5,1.4,0.2,"setosa"
"2",4.9,3,1.4,0.2,"setosa"
"3",4.7,3.2,1.3,0.2,"setosa"
"4",4.6,3.1,1.5,0.2,"setosa"
"5",5,3.6,1.4,0.2,"setosa"
"6",5.4,3.9,1.7,0.4,"setosa"
Even without all those quote characters, it's difficult to tell what goes where.
Last of all, please do not put pipe characters between columns, as is seen in the output from some commands, unless you're demonstrating such a command (e.g., database access from a sql prompt). That is not more human-readable and makes machine-readability harder. Here's an example:
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species
1 | 5.1 | 3.5 | 1.4 | 0.2 | setosa
2 | 4.9 | 3.0 | 1.4 | 0.2 | setosa
3 | 4.7 | 3.2 | 1.3 | 0.2 | setosa
4 | 4.6 | 3.1 | 1.5 | 0.2 | setosa
5 | 5.0 | 3.6 | 1.4 | 0.2 | setosa
6 | 5.4 | 3.9 | 1.7 | 0.4 | setosa