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
HI Eliza,
I looked into your data.
It's not a list of matrices, but a "list of data.frames" and as suspected, some
of the columns were "chr" instead of "num".
str(d) #only selected list elements which showed the anomaly
$ :'data.frame': 1998 obs. of 13 variables:
..$ Col0 : num [1:1998] 1 2
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
Hi,
Check this link
http://tolstoy.newcastle.edu.au/R/help/05/04/1765.html
set.seed(15)
list1<-lapply(1:3,function(i) matrix(sample(1:10,6,replace=TRUE),ncol=i) )
lapply(list1,function(x) colMeans(x,na.rm=TRUE))
[[1]]
#[1] 6.67
#[[2]]
#[1] 6.33 6.00
##
#[[3]]
#[1] 7.0 9.0 7.5
A.K.
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
12 matches
Mail list logo