![]() |
VOOZH | about |
In this article, we are going to see how to replace character value with NA in R Programming Language.
We can replace a character value with NA in a vector and in a dataframe.
In a vector, we can replace it by using the indexing operation.
Syntax:
vector[vector == "character"] <- NA
Output:
[1] "a" "d" "A" "g" NA NA "t" NA "e" NA
Replace character value with NA in dataframe.
Syntax:
dataframe[dataframe== "character"] <- NA
Output:
X.a. X.d. X.A. X.g. X.S. X.S..1 X.t. X.S..2 X.e. X.S..3 1 a d <NA> g S S t S e S