I can use write.table function to create an output data from a data.frame:
> write.table(head(cars), sep = "|", row.names=FALSE)
"speed"|"dist"
4|2
4|10
7|4
7|22
8|16
9|10
How can I create my own write.table function which creates an output like this (header with double pipes and data with preceding and succeeding pipes)?:
||"speed"||"dist"||
|4|2|
|4|10|
|7|4|
|7|22|
|8|16|
|9|10|
write.table. Do you want this function for writing to a file or displaying on screen?||"speed"||"dist"||(I understand the first double-pipe as there is an extra column of row numbers in the data but not in the header). But what's the function of the other two||? So you have 6 separators in the header but only 4 in data? Otherwise, something likewrite.pipetable <- function(obj, file) write.table(obj, file, sep="|")is the likely answer. (Plus if you really need extra separators at the end and beginnig of the lines, you could add just empty columns to the left and right, and usena=""-row.names=FALSEinwrite.table