How would you create a function that manually calculates pearson correlation in r. I know that there is a native function called cor, but what if I want to apply the below equation in R to each combination of columns in a data frame, how would I do it?
I wish I knew how, but I believe it requires many for-loops, nested for-loops etc to make it happen and I am not that strong at programming yet. I hope someone will attempt such that a newbie like me can learn. Thanks
Example:
  set.seed(1)
  DF = data.frame(V1 = rnorm(10), V2=rnorm(10), V3=rnorm(10), V4=rnorm(10))
  #     V1    V2    V3    V4
  # V1  1.00 -0.38 -0.72 -0.24
  # V2 -0.38  1.00  0.60  0.18
  # V3 -0.72  0.60  1.00  0.08
  # V4 -0.24  0.18  0.08  1.00

 
     
     
    