0

When I run the example for the response.plot2 function (biomod2 package) I get the above error. The code produces some plots but does not save an object

Here's the example (including the code that I ran): https://www.rdocumentation.org/packages/biomod2/versions/3.3-7.1/topics/response.plot2 )

[edit:] The source code for the function response.plot2 is here: https://r-forge.r-project.org/scm/viewvc.php/checkout/pkg/biomod2/R/response.plot.R?revision=728&root=biomod

It includes these lines:

.as.ggdat.1D <-
  function (rp.dat) 
  {
    # requireNamespace('dplyr')
    out_ <- bind_rows(lapply(rp.dat, function(dat_) {
      dat_$id <- rownames(dat_)
      id.col.id <- which(colnames(dat_) == "id")
      expl.dat_ <- dat_ %>% dplyr::select(1, id.col.id) %>% 
        tidyr::gather("expl.name", "expl.val", 1)
      pred.dat_ <- dat_ %>% dplyr::select(-1, id.col.id) %>% 
        tidyr::gather("pred.name", "pred.val", (1:(ncol(dat_)-2)))
      out.dat_ <- dplyr::full_join(expl.dat_, pred.dat_)
      out.dat_$expl.name <- as.character(out.dat_$expl.name)
      out.dat_$pred.name <- as.character(out.dat_$pred.name)
      return(out.dat_)
    }))
    out_$expl.name <- factor(out_$expl.name, levels = unique(out_$expl.name))
    return(out_)
  }

I tried changing ncol(dat_) to base::ncol(dat_) and then running the whole lot to redefine the function response.plot2 for my R session, but I got a different error message:

Error in base::ncol : could not find function "::"

Mark
  • 7,785
  • 2
  • 14
  • 34
Tristan
  • 51
  • 1
  • 3
  • do you have a variable or a new function called ncol???? – StupidWolf Oct 29 '19 at 09:52
  • Thanks for the suggestion. I don't have any objects called ncol. The code for the function doesn't create any objects of that name either (the only place it appears is as the function ncol(...) or as an argument in some other function, e.g. matrix(...,ncol = ...) – Tristan Oct 30 '19 at 04:49
  • this is super weird. I installed the package, ran the example, and response.plot2 works for me. which R are you on? I will not try to hack the function. There must be some clashes in your environment – StupidWolf Oct 30 '19 at 08:39

0 Answers0