How to take average of vector values