Operation with large array

2

People would like to know how I can make the squared Euclidean distance between the octadimensional vectors of b and those that are not in a in a super matrix like this one in the example.

I thought so and it did not work. Anyone have an idea?

I read the entire base:

a = matrix(rnorm(4177*8), ncol = 8)

Just to give an example, I picked up the first 1000:

b = a[1:1000, ]

The function takes the ones that are the same and leaves the different ones:

d = a[!apply(a, 1, function(arow) any(apply(b, 1, function(brow) all(brow==arow)))),]

distancia = t(d - b)%*%(d - b)

But I have the following error:

  

Error in d - b: non - conformable arrays

    
asked by anonymous 21.06.2015 / 02:10

1 answer

0

The question is how to set an appropriate a array.

If you use:

N=2000
a = matrix(rnorm(N*2*8), ncol = 8)
#b = a[1:N, ]
#para fazer a questão mais desafiadora pode definir b com linhas aleatórias de a
b = a[sample(2*N,N), ]

Your problem would have a solution.

    
24.06.2015 / 23:40