I want to calculate the correlation between variables which aren't normally distributed, so I am trying to use Spearman. There are some missing values and I don't know how to handle them.

The cor function documentation in R says:

"In the case of missing values, the ranks are calculated depending on the value of use, either based on complete observations, or based on pairwise completeness with reranking for each pair."

It also says:

"For cov and var, "pairwise.complete.obs" only works with the "pearson" method."

So how do I set "or based on pairwise completeness with reranking for each pair" as a criteria for "use"?

cor(df, method="spearman", use=WHAT?)
  • $\begingroup$ Non-normal distributions really aren't a sufficient reason not to use Pearson correlation. The only issue might be how else to get at P-values or more generally carry out statistical inference. Much discussed here. See e.g. stats.stackexchange.com/questions/3730/… $\endgroup$
    – Nick Cox
    Mar 16, 2020 at 12:59

1 Answer 1



rcorr(as.matrix(data), type="spearman")

But I have used in the past. Cant try right now since I'm at lunch. EDIT: This worked for me.

cor(data, method = 'spearman', use='pairwise.complete.obs')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.