i need to know the index of A that give me element!

i tried to use "which" but i don't know how to indicate the element. The only way to do that that i found is:

vector_of element=abs(abs(abs(k[i]*A)-Q)-mean(Q))[-which(B==B)] # vector 1x200 - elements of B (1x50) result vector 1x150
element=min(vector_of_element)
index_element=which(vector_of_element==element)

do you know a way to do that from the previous string?

I think you should share some of your data so we know what you're trying to do. The vectors are different lengths, so they will be recycled - you might get a warning about this. Do you intend this?

which(B==B) is meaningless, B is always == B, so the result will be seq(length(B))
A[-which(B==B)] will therefore remove the first length(B) elements from A
I don't think this is what you are trying to do?

apart from this, you could put the result in temp and then find the position of the min of temp (there could be more than one)

temp <- abs(abs(abs(k[i]*A[-which(B==B)])-Q[-which(B==B)])-mean(Q))
element <- which(temp == min(temp))