I am now dealing with large matrix data and want to accelerate the speed. At first I think parallelization may be a good solution, but then I was told that parallelization for a single call is not possible.
Here is an example,When I try the following code, the speed is not increased as the CPU occupation of the desktop remains around 30%, which is the normal value. So, my question is how to accelerate the calculation speed for just one-line code in R?
set.seed(1234)
mydata=rnorm(5000*150)
mydata=matrix(mydata,ncol=150)
library(parallel)
cl.cores <- detectCores()
cl <- makeCluster(cl.cores)
clusterSetRNGStream(cl,iseed=1234)
clusterExport(cl,"mydata")
clusterEvalQ(cl,library(NbClust))
nc = clusterApply(cl,2,function(min.nc) fun=NbClust(mydata,min.nc=min.nc,max.nc = 8,method = "kmeans"))
stopCluster(cl)