1

I am using R. I am working with a library called "mco" : https://cran.r-project.org/web/packages/mco/index.html

I was looking over some of the function definitions used in this library at the github repository, for example: https://github.com/olafmersmann/mco/blob/master/R/nsga2.R

Over here, I came across the following lines of code:

res <- .Call(do_nsga2,
               ff, cf, sys.frame(),
               as.integer(odim),
               as.integer(cdim),
               as.integer(idim),
               lower.bounds, upper.bounds,
               as.integer(popsize), as.integer(generations),
               cprob, as.integer(cdist),
               mprob, as.integer(mdist))
  if (1 == length(res)) {
    res <- res[[1]]
    names(res) <- c("par", "value", "pareto.optimal")
    class(res) <- c("nsga2", "mco")
  } else {
    for (i in 1:length(res)) {
      names(res[[i]]) <- c("par", "value", "pareto.optimal")
      class(res[[i]]) <- c("nsga2", "mco")
    }
    class(res) <- "nsga2.collection"
  }
  return (res)
}

In the very first line of this code, it makes reference to some object called "do_nsga2". But apart from this function, I can't find any reference to "do_nsga2" within the entire package.

Does anyone know what exactly is being "called"?

Thanks

Note: I am trying to copy/paste all the functions from the github repository into my R session, since I am working with an older computer in which directly installing libraries from CRAN is not possible. When I tried to copy/paste all these functions, I got the following error:

Error in nsga2....  
  object 'do_nsga2' not found
stats_noob
  • 5,401
  • 4
  • 27
  • 83
  • 1
    `.Call` is an interface to compiled code. See [this FAQ](https://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function). – Roland Jul 21 '21 at 06:56
  • 1
    You need to install the package. How old your computer is shouldn't matter. If you are able to run a sufficiently recent version of R to use this package, you are able to install packages. – Roland Jul 21 '21 at 06:58
  • @Ronak Shah: thank you for your reply! Does this mean that "do_nsga2" is being created within the code? Where is "do_nsga" being compiled? – stats_noob Jul 22 '21 at 14:28
  • @Ronald: thank you for your reply! Is it absolutely necessary to install this library? I can't just paste all the github code into R? I know that most times pasting github code doesnt work because a library usually links to other libraries - but in this case, the "mco" library does not appear to be doing this. Therefore, should this not be possible? Thanks! – stats_noob Jul 22 '21 at 14:33
  • @Ronak Shah: I normally use the "getAnywhere" function in R to view the source code. – stats_noob Jul 22 '21 at 14:36
  • 2
    This package contains compiled code. Getting it to work without building the package will be more difficult than simply buidling the package. – Roland Jul 22 '21 at 14:45

0 Answers0