This note compares the performance of 2 methods for calculating Pearson correlation: 1. R stats::cor function 2. WGCNA::cor function (or corFast) SparkR (1.6) provides a function corr to calculate the Pearson correlation between two columns of a data frame, but not between every pair of columns in a data frame. We would need to use Scala/Python interface for that. Correlation at 100 data points library(WGCNA) enableWGCNAThreads(nThreads = 32) ## Allowing parallel execution with up to 32 working processes.

Continue reading

Digit count

What is the better way to count the number of digit in a number? digit_count recursively divide the number by its base (10) cast it into string and use str_length to count the number of characters digit_count <- function(number,count=1) { if (number < 10) {return(count)} return(digit_count(number %/% 10, count=count+1)) } Definitions a = function(x) {return(digit_count(x))} b = function(x) {return(stringr::str_length(as.character(1000)))} Timing

Continue reading

Author's picture

Trang Tran


Student

USA