Write a function in R language to replace the missing value in a vector with the mean of that vector?
Answer / Ankur
Here is a simple function named `fill_mean()` that replaces NA values in a vector with the mean of the non-NA values:
```R
fill_mean <- function(vector) {
if (any(is.na(vector))) {
vector[is.na(vector)] <- mean(vector, na.rm = TRUE)
}
return(vector)
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
Describe substr() in r string manipulation?
What is more functions in r and name them?
Explain disadvantages of density-based clustering in R?
What is functional programming and memory issues in on the performance basis?
Write the r programming code for an array of words so that the output is displayed in decreasing frequency order?
What do you understand by R cluster analysis?
Why the stepaic()?
Explain What is R?
how to import data into R?
How can you resample statistical tests in r language?
How can you create a pca model in r?
What is the Use of String Utilities in the edtdbg Debugging Tool in R string manipulation?