How to Solve R Error in lm.fit: na/nan/inf

This error occurs when trying to fit a linear regression model in R using the lm() function but either the predictor or response variables contain Not a Number (NaN) or infinity (Inf) values. You can solve this error by replacing the NaN and Inf values with NA values,...