79748051

Date: 2025-08-27 13:44:33
Score: 1
Natty:
Report link

I don't exactly know how your error is occurring, as I cannot seem to replicate it myself. I'm getting your desired dataframe as output even with your code. That said, the below works as well, and relies on dplyr from the tidyverse

library(tidyverse)
library(vegan)

caract_sites <- caract_sites |> #|> is the same as %>%, but preferred by the r style guide
  mutate(specnumber = specnumber(site_sp_ok))

When adding or changing rows in a dataframe I find dplyr::mutate() works well for me.

Reasons:
  • Blacklisted phrase (0.5): I cannot
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Peregrine9991