Articles

Affichage des articles du octobre, 2023

Print messages on console during parallel computing

An exemple that print messages during parallel computing library(pbmcapply) # Can work with mclapply also cores <- 2 lazyChattySqrt <- function(num, name) {      # Sleep 2 seconds      Sys.sleep(2)      system(sprintf("echo '\nHello\n'"))      return(sprintf("Hello %s, the sqrt of %f is %f.", toString(name), num, sqrt(num)))  } chattyResult <- pbmclapply(1:3, lazyChattySqrt, "Bob", mc.cores = cores)

Install RNetCDF in Ubuntu 22

 I was force to do: cd /usr/lib/R/ mkdir share cd share mkdir make cd /usr/lib/R/share/make/ sudo ln -s /usr/share/R/share/make/shlib.mk shlib.mk And then in R,  install.packages("RNetCDF", type="source") was possible.

Binomial confidence limit

Hmisc: version 5.1-1 binom: version 1.1-1.1 binomCI: version 1.0 DescTools:  version 0.99.50 I just notice a difference when x=1 or x=n-1 is observed between the different implementations of the Wilson method: n <- 2 x <- 1 sr_binom <- binom::binom.confint(x=x, n=n, methods = "wilson", conf.level = 0.95) sr_Hmisc <- Hmisc::binconf(x=x, n=n, method = "wilson", alpha = 0.05) sr_binomCI <- binomCI::binomCI(x=x, n=n, a = 0.05) # Warning message: # In sqrt(n - z^2 - 2 * z/sqrt(n) - 1/n) : NaNs produced sr_binom #   method x n mean      lower     upper # 1 wilson 1 2  0.5 0.09453121 0.9054688 sr_Hmisc  # PointEst      Lower     Upper  #     0.5 0.02564665 0.9743534 sr_binomCI$ci["Wilson", ] #    0.025%     0.975%  # 0.09453121 0.90546879  No difference between packages is observed for x=2 for example with n <- 4 and x <- 2. The discrepancy is not observed also with exact method (or exact binomial). When checking the code, I see that in packa