Kendallknight: an R package for Kendall’s correlation coefficient
A solution that took me hours of ‘averaging’ Google search results and using my brain.
Motivation
Existing R packages, such as pcaPP, provide efficient implementations of the Kendall correlation coefficient. However, I wanted to create my own package exclusively for this purpose, without additional functions, and that it also allows to test hypothesis about the correlation coefficient.
Installation
You can install the development version from GitHub with:
::install_github("pachadotdev/Kendallknight") remotes
Usage
library(kendallknight)
<- c(1, 2, 3, 4, 5)
x <- c(5, 4, 3, 2, 1)
y
kendall_cor(x, y)
kendall_cor_test(x, y, "two.sided")
> kendall_cor(x, y)
1] -1
[
> kendall_cor_test(x, y, "two.sided")
$statistic
1] -1
[
$p_value
1] 0.01666667
[
$alternative
1] "alternative hypothesis: true tau is not equal to 0" [
Details
The package is mostly implemented in C++ using cpp11 to export the functions to R.