I'm trying to calculate sample covariance between these two vectors. I defined a function with two input variables. I don't know if it is correct? Also my formula for sample covariance won't run. Can anyone help me write it out in R?
xv = c(1., 5.5, 7.8, 4.2, -2.7, -5.4, 8.9)
yv = c(0.1, 1.5, 0.8, -4.2, 2.7, -9.4, -1.9)
sampleCov= function(x,y){
cov(xv,yv) = frac{sum_{i=1}^{n}(x_i-\mu_x)(y_i-\mu_y)}{n-1}].
return (Cov(xv,yv)
}