Thank you Dimitris!
I have 3D arrays of the same dimensions, so Reduce worked...
Best,
Eleni
On Thu, Mar 4, 2010 at 5:13 PM, Dimitris Rizopoulos <
d.rizopou...@erasmusmc.nl> wrote:
> do these lists contain 3D arrays of the same dimensions? If yes, then you
> could use
>
> Reduce("+", pred.svm[
do these lists contain 3D arrays of the same dimensions? If yes, then
you could use
Reduce("+", pred.svm[[i]])[1,2,5]
otherwise a for-loop will also be clear and efficient, e.g.,
W <- pred.svm[[i]][[1]][1,2,5]
for (j in 2:20) {
W <- W + pred.svm[[i]][[j]][1,2,5]
}
I hope it helps.
Best
Dear list,
I have some difficulty in manipulating list elements. More specifically, I
am performing svm regression and have a list of lists, called pred.svm. The
elements of the second list are 3D arrays. Thus I have pred.svm[[i]][[j]],
with 1<=i<=5 and 1<=j<=20.
I want to take the sum of the elem
My guess is that the original
poster is expecting a matrix
not a scalar. If so, then:
> Reduce('+', a)
[,1] [,2] [,3]
[1,]300
[2,]030
[3,]003
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of "The R Inferno" an
On Jul 2, 2009, at 11:24 PM, David Winsemius wrote:
On Jul 2, 2009, at 10:20 PM, Ivo Shterev wrote:
a = list(diag(3), diag(3), diag(3))
a = list(diag(3), diag(3), diag(3))
> sum(unlist(a))
[1] 9
Also:
> sum(sapply(a,I))
[1] 9
David Winsemius, MD
Heritage Laboratories
West Hartford,
On Jul 2, 2009, at 10:20 PM, Ivo Shterev wrote:
a = list(diag(3), diag(3), diag(3))
a = list(diag(3), diag(3), diag(3))
> sum(unlist(a))
[1] 9
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
__
R-help@r-project.org mailing list
https
I think you are asking for Reduce
> Reduce(`+`, a)
[,1] [,2] [,3]
[1,]300
[2,]030
[3,]003
>
You might be asking for do.call with some function's name as its first
argument.
> do.call("sum", a)
[1] 9
>
__
R-h
Dear All,
Is there an automatic way to sum the elements of a list?
For example given a = list(diag(3), diag(3), diag(3)) to obtain
b=a[1]+a[2]+a[3].
Thanks
Ivo
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE d
8 matches
Mail list logo