I have a long complex array, on which I would like to do
rowsum(my_array, group = factors)
Unfortunately, rowsum does not accept complex numbers while rowSums does but does not accept factors, to average over the rows.
What would you would recommend?
Edit: example
my_array <- array(c(1+1i, -1-1i, 2, 0, 1+1i, 2+2i), dim = c(3, 2))
factors <- c(1, 1, 2)
Expected response:
[,1] [,2]
[1,] 0 1+1i
[2,] 2 2+2i
2nd edit:
The factors are applied for each column individually and here 0 == 1+1i + (-1-1i)
and 1+1i == 0 + 1+1i
.