[R] write matrix M including names(dimnames(M))

David Winsemius dwinsemius at comcast.net
Sat Aug 1 19:11:52 CEST 2009


On Jul 30, 2009, at 11:50 PM, Steve Jaffe wrote:

>
> I can do this by writing (and reading) the file according to some  
> format of
> my own devising, but I'm wondering if there is a built-in way to  
> write and
> then restore a matrix with not only the dimnames (which
> write.table/read.table can preserve) but also the names(dimnames)?
>
> Example:
>> M <- matrix(1:4, 2, 2)
>> dimnames(M) <- list(xdim=c("a", "b"), ydim=c("u", "v"))
>> M
>    ydim
> xdim u v
>   a 1 3
>   b 2 4

There are two such matched combinations for saving R objects complete  
with attributes:

dput/dget  # will be more readable with a text editor than the next  
option

save/load  # not very readable

>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list