79766088

Date: 2025-09-16 10:11:29
Score: 0.5
Natty:
Report link

After a bit of research on gg_ordisurf github source code, the problem was coming from this part of the code function:

  # Calculate default binwidth
  # Can change the binwidth depending on how many contours you want
  if(missing(binwidth)) {
    r <- range(env.var)
    binwidth <- (r[2]-r[1])/15
  } else {
    binwidth = binwidth
  }

so I added na.rm=TRUE in the range function:

  # MODIFED gg_ordisurf function
  if(missing(binwidth)) {
    r <- range(env.var, na.rm = TRUE)
    binwidth <- (r[2]-r[1])/15
  } else {
    binwidth = binwidth
  }

and made my own gg_ordisurf function by copying the source code.

Note: the vegan::ordisurf function was working perfectly fine with this issue.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Maxime Buron