Description Usage Arguments Details Examples
Sets a range of values to NA
1 |
x |
a vector of values within which some values should be set to NA |
na.vector |
a vector of values that should be changed to NA |
Creates a regex from na.vector and uses this to set values as NA.
Values in na.vector are 'wrapped' with '^' and '$' to add specificity.
Some characters need to be escaped to form regexs.
See regex
for details.
1 2 3 4 5 6 7 8 9 10 11 12 | myData <- data.frame(matrix(ncol=4, nrow=12))
colnames(myData) <- paste('char', 1:ncol(myData), sep="_")
rownames(myData) <- paste('sample', 1:nrow(myData), sep="_")
set.seed(9)
myData[,1] <- abs(round(rnorm(nrow(myData), mean = 5, sd =2)))
myData[,2] <- letters[myData[,1]]
myData[,3] <- as.factor(myData[,2])
myData[,4] <- factor(myData[,2], ordered = TRUE)
myData[3,2] <- "?" # Add an nexpected value
myData[4,2] <- "-999" # Add an nexpected value
myData[,2] <- set_na(myData[,2])
myData
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.