phicoef function calculates the "phi coefficient" between
two binary variables.
Two logical vectors of the same length.
The "phi coefficient" between the two binary variables. This is a single numeric value ranging from -1 to +1.
1 2 3 4 5 6 7 8 9 10
set.seed(33) x <- sample(c(TRUE, FALSE), 100, replace=TRUE) y <- sample(c(TRUE, FALSE), 100, replace=TRUE) phicoef(x, y) phicoef(rep(x, 10), c(rep(x, 9), y)) stopifnot(phicoef(table(x, y)) == phicoef(x, y)) stopifnot(phicoef(y, x) == phicoef(x, y)) stopifnot(phicoef(x, !y) == - phicoef(x, y)) stopifnot(phicoef(x, x) == 1)
Loading required package: stats4 Loading required package: BiocGenerics Loading required package: parallel Attaching package: 'BiocGenerics' The following objects are masked from 'package:parallel': clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport, clusterMap, parApply, parCapply, parLapply, parLapplyLB, parRapply, parSapply, parSapplyLB The following objects are masked from 'package:stats': IQR, mad, xtabs The following objects are masked from 'package:base': Filter, Find, Map, Position, Reduce, anyDuplicated, append, as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which, which.max, which.min Loading required package: S4Vectors Attaching package: 'S4Vectors' The following objects are masked from 'package:base': colMeans, colSums, expand.grid, rowMeans, rowSums Loading required package: IRanges Loading required package: GenomeInfoDb  -0.09785447  0.8899124
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.