Description Usage Arguments Details Value Author(s) Examples
Given a vector (numeric, character, double, factor) with missingness coded as not NA
, replace it as NA
. Some examples are - 9 N/A Unknown, Not Available etc.
1 | replaceNAs(x, vNA)
|
x |
A vector of values - numeric, character, double or factor. |
vNA |
A character vector of values to be replaced that are coded as missing into |
Both arguments should be supplied. If typeof
is not matched to one of the following - character, double, integer
or factor
, a character
vector is returned
x.na |
A vector with misisng values coded as |
Arshi Arora
1 2 3 4 5 6 7 8 | set.seed(123)
#sample 20 numbers from 1 -10, say we want to replace the 9s to NA
x<-sample(1:10, 20, replace=TRUE)
#x
#[1] 3 8 5 9 10 1 6 9 6 5 10 5 7 6 2 9 3 1 4 10
x.na<-replaceNAs(x,9)
#[1] 3 8 5 NA 10 1 6 NA 6 5 10 5 7 6 2 NA 3 1 4 10
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.