Title says it all, I created a composite index which has some NaN's in it. How would I go on and remove theses NaN's from a specific column (my composite index)?
I have looked at is.nan() but that just tells me if it's NaN or not...
Title says it all, I created a composite index which has some NaN's in it. How would I go on and remove theses NaN's from a specific column (my composite index)?
I have looked at is.nan() but that just tells me if it's NaN or not...
You can use an if-else statement with is.nan() as the conditional and set the value to 0 on true else set the value to the number.
More information here: Does the ternary operator exist in R?
From the link, credit to the author of that accepted answer for the following example(s) of code:
if-else
> x <- if(a==1) 1 else 2
> x
[1] 1
> x <- if(a==2) 1 else 2
> x
[1] 2