Replace Inf with NA in Dataframe in R
In this article, we will discuss how to replace Inf (Infinity) with NA in Dataframe in R Programming Language.
Create a dataframe with for demonstration:
So we can replace Inf with NA by using lapply() function, we have to create our own function to replace Inf with NA and then pass that function to lapply() through do.call method.
function(value) replace(value, is.infinite(value), NA)
Where value is the input value and replace() is used to replace the value to NA if it is infinite.
Example 1: R program to replace Inf value with NA in the dataframe