[R] help with parellel processing and RSelenium

akshay kulkarni @k@h@y_e4 @end|ng |rom hotm@||@com
Sun Dec 12 17:43:44 CET 2021


dear members,
                         I am a stock trader based in INDIA using R for my research. I have two questions:


  1.  I want to send the same function with different arguments to different cores. This link in SO https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
  2.  gives the following solution:

   library(parallel)

cl <- makeCluster(4)
clusterExport(cl, "foo")
cores <- seq_along(cl)
r <- clusterApply(cl[cores], cores, function(core) {
  if (core == 1) {
    foo(5, 4, 1/2, 3, "a")
  } else if (core == 2) {
    foo(5, 3, 1/3, 1, "b")
  } else if (core == 3) {
    foo(5, 4, 1/4, 1, "c")
  } else if (core == 4) {
    foo(5, 2, 1/5, 0, "d")
  }})

My question is: what is the structure of the output "r" in the above code? I think it is a list with r[[1]] = output of foo(5,4,1/2,3,"a"),r[[2]] = output of foo(5,1/3,1,"b")

and so on. AM I right?

  1.

I am using RSelenium to scrape a website. Javascript has a document.ready function which ensures that any JS code is run only after the whole document is

  *

loaded. Is there a similar function in RSelenium? Or will the execution of the next expression takes place only after the whole page is loaded (with the

  *

"navigate" method of RSelenium)?

Thanking you,

Yours sincerely,

AKSHAY M KULKARNI




	[[alternative HTML version deleted]]



More information about the R-help mailing list