Friday, February 28, 2014

Remove NA values in a data frame in R

Hi everybody,

Just a little post for today, but it is something that will be really useful in many occasions.

If you had read the post of yesterday, you probably noticed that there were some NA values in the final dataset, however NA values are sometime not desired and you would like to replace them with another value.

We use the function is.na to select the NA values in the dataset and then replace them with 0.
myData[is.na(myData)] <- 0

No comments:

Post a Comment