Covariance is a measure of how much two variables “change together.” It is positive when the variables tend to increase or decrease together, and negative when they upward motion of one variable is correlated with downward motion of the other. Correlation normalizes covariance to the interval $[-1,1]$.
Solution
We will construct some random data here, but when applying this, you would use your own data, of course.
1
2
3
4
5
# Create a dataframe with random values between 0 and 1set.seed(1)df<-as.data.frame(matrix(runif(n=50,min=0,max=1),nrow=10))names(df)<-c('col1','col2','col3','col4','col5')head(df)