Search code examples
rvectormedian

Returning the median from two vectors in r


I have a vector containing the minimum and maximum of 3 ranges i.e

low<-1,2,3
high<-2,3,4

represent the ranges 1-2,2-3,and 3-4

I need to return a third vector containing the midpoint of each range i.e.

mid<-1.5,2.5,3.5

Any quick way to do this?


Solution

  • Assuming you've actually got low <- c(1, 2, 3) etc, then:

    mid <- (low + high)/2