I am trying to calculate the correlation coefficient in a large set of data and can't quite get the mutate function to work.
This is an example of my data
Z A B 1.3 0.9 0.75 1.6 0.5 0.3 1.9 0.2 0.1
I am trying to calculate the coefficients for Z & A, Z & B.
mutate(cor = map(data, ~cor(.x$A, .x$B))) %>%
unnest(cor, .drop = TRUE)
That was the code I am inputting however this is the result:
# A tibble: 3 x 3 # Groups: Z  Z data cor <dbl> <list> <dbl> 1 13 <tibble [1 × 2]> NA 2 16 <tibble [1 × 2]> NA 3 9 <tibble [1 × 2]> NA
Is it possible to get the correlations for A & B to appear in my console in this format instead of NA?