Re: [R] reading matrix objects into a list

From: Huntsinger, Reid <reid_huntsinger_at_merck.com>
Date: Fri 14 Oct 2005 - 05:57:54 EST


Try

x <- list(A)

instead. Coercion (as.list) sees A as a vector of length 90,000 (forgetting the "dim" attribute) and assumes you want to make it a "generic vector", which conceptually just changes its mode to "list", whereas "list" constructs a list with entries you pass as arguments.

Reid Huntsinger

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Paul Baer Sent: Thursday, October 13, 2005 3:41 PM
To: r-help@stat.math.ethz.ch
Subject: [R] reading matrix objects into a list

OK, I've tried to be a good citizen and use the searchable archives, but with three search strings I haven't found the answer to what must really be a simple question.

I want to create a list of objects from a set of matrices (in this case, 300x300). Suppose the first matrix is A. I tried:

> x=as.list(A)

But it I get a list of length 90,000

> length(x)

[1] 90000

instead of length 1, which is what I expected.

What's the simple trick I'm missing?

Thanks,

--Paul



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Oct 14 06:04:17 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:51:09 EST