I am trying to change a function stats::kmeansto return the number of iterations ( see here ). When I copy the source to my own file, modify the function and run it, I get an error message about the object C_kmnswhen I try to execute the function do_one. This object is passed to the call .Fortranand is not created anywhere in the function kmeans. Where does this object come from?
The error I get is
Error in do_one(nmeth) : object 'C_kmns' not found
Here is a snippet of an “abusive” call.
do_one <- function(nmeth) {
Z <-
switch(nmeth,
{
Z <- .Fortran(C_kmns, as.double(x), as.integer(m),
as.integer(ncol(x)),
...
source
share