...
No Format |
---|
length(.packages(all.available=TRUE)) ip <- as.data.frame(installed.packages()[, c(1, 3:4)]) rownames(ip) <- NULL ip <- ip[is.na(ip$Priority), 1:2, drop=FALSE] print(ip, row.names=FALSE) For example: > length(.packages(all.available=TRUE)) [1] 200 > ip <- as.data.frame(installed.packages()[, c(1, 3:4)]) > rownames(ip) <- NULL > ip <- ip[is.na(ip$Priority), 1:2, drop=FALSE] > print(ip, row.names=FALSE) Package Version abind 1.4-5 acepack 1.4.1 anchors 3.0-8 askpass 1.1 |
How to run R code in parallel : Parallelisation using dplyr and doParallel
Parallelisation using plyr and doParallel
We have plyr and DoParallel in R/4.0.3
Threads vs. cores
There is often a lot of confusion between CPU threads and cores. A CPU core is the actual computation unit. Threads are a way of multi-tasking, and allow multiple simultaneous tasks to share the same CPU core. Multiple threads do not substitute for multiple cores. Because of this, compute-intensive workloads (like R) are typically only focused on the number of CPU cores available, not threads. (Ref: https://jstaf.github.io/hpc-r/parallel/)
No Format |
---|
Example:
module load R/4.0.3
> library(plyr)
> library(doParallel)
Loading required package: foreach
Loading required package: iterators
Loading required package: parallel
> cores <- detectCores()
> cores
[1] 72
> registerDoParallel(cores=12)
> fake_func <- function(x) {
+ Sys.sleep(0.1)
+ return(x)
+ }
>
> library(microbenchmark)
> microbenchmark(
+ serial = llply(1:24, fake_func),
+ parallel = llply(1:24, fake_func, .parallel = TRUE),
+ times = 1
+ )
Unit: milliseconds
expr min lq mean median uq max neval
serial 2424.3580 2424.3580 2424.3580 2424.3580 2424.3580 2424.3580 1
parallel 226.2199 226.2199 226.2199 226.2199 226.2199 226.2199 1
>
|
Reference
1. http://yusung.blogspot.com.au/2009/01/install-jags-and-rjags-in-fedora.html
...