I just discovered the following behaviour of the is.na() function which I don\'t understand:
df <- data.frame(a = 5:1, b = \"text\")
df
## a
The actual function being used here is not is.na() but the assignment function `is.na<-`, for which the default method is `is.na<-.default`. Printing that function to console we see:
function (x, value)
{
x[value] <- NA
x
}
So clearly, value is supposed to be an index here. If you index a data.frame like df["0"], it will try to select the column named "0". If you assign something to df["0"], the column will be created and filled with (in this case) NA.
To clarify, `is.na<-` sets values to NA, it does not replace NA values with something else.