thanks to all!
didn't know about simplify2array, nor about the abind package.
they're exactly what i wanted.
cheers,
-m
On Sun, Feb 17, 2013 at 9:41 AM, Tony Plate wrote:
> abind() (from package 'abind') can take a list of arrays as its first
> argument, so in general, no need for do.call() wit
abind() (from package 'abind') can take a list of arrays as its first argument,
so in general, no need for do.call() with abind().
As another poster pointed out, simplify2array() can also be used; while abind()
gives more options regarding which dimension is created and how dimension names
are
On Feb 13, 2013, at 10:03 PM, Murat Tasan wrote:
i'm somehow embarrassed to even ask this, but is there any built-in
method for doing this:
my_list <- list()
my_list[[1]] <- matrix(1:20, ncol = 5)
my_list[[2]] <- matrix(20:1, ncol = 5)
now, knowing that these matrices are identical in dimensi
require(abind)
do.call(abind,c(my_list,list(along=0))) # Gives 2 x 4 x 5
do.call(abind,c(my_list,list(along=3))) # Gives 4 x 5 x 2
The latter seems more natural to me.
cheers,
Rolf Turner
On 02/14/2013 07:03 PM, Murat Tasan wrote:
i'm somehow embarrassed to even ask this, but is
3 AM
Subject: Re: [R] list of matrices --> array
FYI - this is my current method, but somehow i just don't like it ;-)
foo <- array(NA, dim = c(4,5,length(my_list)))
for(k in 1:length(my_list)) {
foo[,,k] <- my_list[[k]]
}
-m
On Thu, Feb 14, 2013 at 1:03 AM, Murat Tasan wrote:
>
FYI - this is my current method, but somehow i just don't like it ;-)
foo <- array(NA, dim = c(4,5,length(my_list)))
for(k in 1:length(my_list)) {
foo[,,k] <- my_list[[k]]
}
-m
On Thu, Feb 14, 2013 at 1:03 AM, Murat Tasan wrote:
> i'm somehow embarrassed to even ask this, but is there any bui
i'm somehow embarrassed to even ask this, but is there any built-in
method for doing this:
my_list <- list()
my_list[[1]] <- matrix(1:20, ncol = 5)
my_list[[2]] <- matrix(20:1, ncol = 5)
now, knowing that these matrices are identical in dimension, i'd like
to unfold the list to a 2x4x5 (or some o
,2)
# Col0 Col1 Col2 Col3 Col4 Col5 Col6 Col7
#sr1 15.72368 458.3062 440.41702 518.4893 853.6490 2169.3466 5144.764 7423.5169
#sr2 15.91228 39.8461 48.15517 103.2362 200.2069 289.7981 427.628 426.8419
# Col8 Col9 Col10 Col11 Col12
#s
88 12529.8313
#[7] 13965.5763 9270.4147 4352.4091 2082.5329 1441.8123 1158.6669
A.K.
From: eliza botto
To: "smartpink...@yahoo.com"
Sent: Wednesday, January 2, 2013 5:41 PM
Subject: RE: [R] list of matrices
dear arun,
can u please try your c
I fail to understand the purpose of your post. The error message seems
clear enough: either your matrices are not all numeric or you may have data
frames among them with non-numeric columns. Have you checked either or both?
?is.matrix
?is.numeric
as in
lapply(s,is.matrix(x) && is.numeric(x))
(wi
A.K.
- Original Message -
From: eliza botto
To: "r-help@r-project.org"
Cc:
Sent: Wednesday, January 2, 2013 5:16 PM
Subject: [R] list of matrices
dear useRs,
i have a list containing 16 matrices. i want to calculate the column mean of
each of them.
i tried
>sr <-
dear useRs,
i have a list containing 16 matrices. i want to calculate the column mean of
each of them.
i tried
>sr <- lapply(s,function(x) colMeans(x, na.rm=TRUE))
but i am getting the following error
>Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
can it be done in any other way? and
You probably want
mylist[[i]] = function(...)
in your loop.
Similarly, when you want them again later, you need to use double
square brackets.
I once heard a useful metaphor for understanding the difference
between [ and [[ when it comes to lists.
If x (a list) is a train, then x[2] is the sec
Use
mylist[[i]] = function(...)
mylist[i] and mylist[[i]] are two different things.
On Wed, Mar 21, 2012 at 11:08 AM, David Zastrau wrote:
> Hello dear R-users,
>
> I am currently trying to fill some datasatructure (array, list, hash...)
> with matrices that are calculated by a function and do v
Hello dear R-users,
I am currently trying to fill some datasatructure (array, list, hash...)
with matrices that are calculated by a function and do vary in size:
mylist = list()
for(i in 1:n)
mylist[i] = function(...) # returns a matrix
print(mylist[1]) # prints only the first element of
15 matches
Mail list logo