Thank you, that's a good idea. I should have looked into that!

On Sep 19, 2011, at 8:42 AM, Paul Hiemstra wrote:

> Sorry, misread :). Consider my remark as retracted...however....
> 
> It looks like it would be relatively simple to rewrite write.matrix a
> little bit to include rownames...the cat statement in the while loop of
> write.matrix could be changed to include a row name. To get he source
> code of write.matrix:
> 
> library(MASS)
> write.matrix
> # without the ()!!
> 
> hope this helps more than my previous (useless) comment,
> Paul
> 
> On 09/19/2011 02:37 PM, Mark Ebbert wrote:
>> I'm afraid I don't understand your response. As I mentioned in the original 
>> question, write.table is way too slow and I need the row names in the file, 
>> so setting row.names to FALSE wouldn't accomplish my goal, anyway. And 
>> write.matrix doesn't have *any* options to include row names, which baffles 
>> me since row names are part of a matrix object. 
>> 
>> I need the row names because an external program, which requires row names, 
>> will be processing the files. I wound up using perl to fix the resultant 
>> file from write.matrix, but I would love to hear an explanation as to why 
>> write.matrix doesn't have an option to include row names, if you know. 
>> 
>> Anyway, thanks for taking the time to respond. 
>> 
>> On Sep 19, 2011, at 1:49 AM, "Paul Hiemstra" <paul.hiems...@knmi.nl> wrote:
>> 
>>> What do you want with the row names? The help file for ?write.table
>>> lists a row.names argument which can be set to FALSE.
>>> 
>>> regards,
>>> Paul
>>> 
>>> On 09/06/2011 02:58 PM, Mark Ebbert wrote:
>>>> Thank you for your help.
>>>> 
>>>> The data is meant to be processed by a separate program that expects a 
>>>> simple matrix with row and column names in ascii format. "write.matrix" 
>>>> does exactly what I want except for the row names. It baffles me that this 
>>>> is not an option…
>>>> 
>>>> 
>>>> On Sep 6, 2011, at 8:22 AM, Paul Hiemstra wrote:
>>>> 
>>>>> On 09/06/2011 06:24 AM, Mark Ebbert wrote:
>>>>>> Dear R gurus,
>>>>>> 
>>>>>> I am trying to write several large matrices (~ 1GB) to separate files. I 
>>>>>> have learned that write.table is simply too slow for this task and was 
>>>>>> attempting to use write.matrix, but write.matrix does not have the 
>>>>>> ability to include row names in the output. Anyone know why that's the 
>>>>>> case? I've seen a thread stating that write.matrix is the way to go for 
>>>>>> large prints to files, but it doesn't do what I need it to. Since 
>>>>>> write.matrix wasn't working I tried both sink and capture.output, but 
>>>>>> then the output is printed to the file using the same 'width' 
>>>>>> restrictions as the general "options(width=)" limit.
>>>>>> 
>>>>>> Any ideas on how to print a large matrix with row names? I could write a 
>>>>>> perl script to modify the files after the fact, but I shouldn't have to 
>>>>>> do that.
>>>>>> 
>>>>>> Thanks for your help!
>>>>>> 
>>>>>> Mark T. W. Ebbert
>>>>>> ______________________________________________
>>>>>> R-help@r-project.org mailing list
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>> PLEASE do read the posting guide 
>>>>>> http://www.R-project.org/posting-guide.html
>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>> Hi,
>>>>> 
>>>>> What do you want with the data? If you want to store an R matrix on disk
>>>>> for later use in R, take a look at ?save. If it is for use in another
>>>>> programming language, I would write the matrix in binary format
>>>>> (?writebin). This saves a lot of space and prevents any (significant)
>>>>> rounding errors. It is probably also quite a bit faster. If you really
>>>>> need some more metadata (such as rownames), I would add a second text
>>>>> file which stores this information. Sort of a binary file plus a header,
>>>>> which is a quite common format for storing data. Maybe you can even find
>>>>> a standard binary format which you can use. But it is impossible to
>>>>> comment on this because you did not provide information as to what you
>>>>> want to do with the saved data.
>>>>> 
>>>>> good luck!
>>>>> Paul
>>>>> 
>>>>> -- 
>>>>> Paul Hiemstra, Ph.D.
>>>>> Global Climate Division
>>>>> Royal Netherlands Meteorological Institute (KNMI)
>>>>> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>>>>> P.O. Box 201 | 3730 AE | De Bilt
>>>>> tel: +31 30 2206 494
>>>>> 
>>>>> http://intamap.geo.uu.nl/~paul
>>>>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>>>>> 
>>> 
>>> -- 
>>> Paul Hiemstra, Ph.D.
>>> Global Climate Division
>>> Royal Netherlands Meteorological Institute (KNMI)
>>> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
>>> P.O. Box 201 | 3730 AE | De Bilt
>>> tel: +31 30 2206 494
>>> 
>>> http://intamap.geo.uu.nl/~paul
>>> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>>> 
> 
> 
> -- 
> Paul Hiemstra, Ph.D.
> Global Climate Division
> Royal Netherlands Meteorological Institute (KNMI)
> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
> P.O. Box 201 | 3730 AE | De Bilt
> tel: +31 30 2206 494
> 
> http://intamap.geo.uu.nl/~paul
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
> 

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to