Public-Health-Scotland / phsmethods

An R package to standardise methods used in Public Health Scotland (https://public-health-scotland.github.io/phsmethods/)
https://public-health-scotland.github.io/phsmethods/
54 stars 13 forks source link

Function to replace NaN values. #64

Closed Nic-Chr closed 4 months ago

Nic-Chr commented 3 years ago

Simple function to replace NaN values, similarly named to tidyr::replace_na().

replace_nan <- function(x, value){
  x[is.nan(x)] <- value
  x
}
Moohan commented 2 years ago

I suggested this at https://github.com/tidyverse/tidyr/issues/1149 and it was rejected as too specific for tidyr. I'm not sure I've ever come across NaN data so I wouldn't have a use for it but I'm assuming at least @Nic-Chr has in the past so the function would be useful!