At 01:39 pm -0500 31/03/04, Raubertas, Richard wrote:
Another alternative is to use the underappreciated function
'sweep()':
sweep(A, 1:2, a, +)
I find the following helpful (it's not due to me but I cannot find
the original poster):
%.+% - function(a,x){sweep(a , 2:1 , x ,+ )}
%+.% -
Hi,
I have noticed the following:
a - array(1:4, c(2, 2))
A - array(1:4, c(2,2,2))
A + a
Error in A + a : non-conformable arrays
It works with a matrix + a vector, why doesn't it work with arrays?
Am I missing something?
How would you do the above operation efficiently (ie I need to add a
:00 AM
To: Tamas Papp
Cc: R-help mailing list
Subject: Re: [R] array addition doesn't recycle!
The recycling rules are documented and this is not amongst them.
Computer packages do have a tendency to follow their rules
rather than
read your mind.
I suspect A + as.vector(a) is what