I’ve got a headerfile with exactly 4 rows in a fixed width format (saved with the write.matrix function from the MASS package).
Now I want to create a new Matrix with the headerfile I created above. Is it possible in R to add a fixed multiline header (e.g. as “text”) to a matrix?
An example: I’ve got a header like
AB
CDEF 123456
GHIJK 789 101112
LMNOP
And then I want to create a matrix with date in first column and then the data (from another file) in the second column like
892201 0.1
892202 0.8
and so on. Note: It has to be the described format, because the program just read the fixed width format explained above.
You can write the second set of data into the existing file using the
write.table()function with theappend = TRUEargument.If I have file
foo.txtwith the header you show, then I can add some dates and other data to that file by first creating the data object I want to append:The the following will append
datwithout any extraneous headers or row names on to the existing header filefoo.txtnow looks like this: