
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between NA and <NA> in R?
The missing values are represented by NA but if we read them as "NA" then it becomes a level of a factor variable. If we believe that a vector is numeric and we have an "NA" in that vector then it will not be a numeric vector. On the other hand, if we have a vector with NA then it will be a numeric vector.
Examples
x1<-c("A","B","NA","D",NA,"F") x1 [1] "A" "B" "NA" "D" NA "F" x1<-factor(c("A","B","NA","D",NA,"F")) x1 [1] A B NA D <NA> F Levels: A B D F NA x2<-factor(c("A","B","D",NA,"F")) x2 [1] A B D <NA> F Levels: A B D F x3<-factor(c("Sweet","Bitter","Salty",NA)) x3 [1] Sweet Bitter Salty <NA> Levels: Bitter Salty Sweet x4<-factor(c("Sweet","Bitter","Salty","NA")) x4 [1] Sweet Bitter Salty NA Levels: Bitter NA Salty Sweet x5<-factor(c("Sweet","Bitter","Salty","NA",NA)) x5 [1] Sweet Bitter Salty NA <NA> Levels: Bitter NA Salty Sweet x6<-factor(c("India","China",NA,"USA","UK")) x6 [1] India China <NA> USA UK Levels: China India UK USA x7<-factor(c("India","China",NA,"USA","UK","NA")) x7 [1] India China <NA> USA UK NA Levels: China India NA UK USA x8<-factor(c("Level1","Level2","Level3","Level4","NA","Level6","Level7")) x8 [1] Level1 Level2 Level3 Level4 NA Level6 Level7 Levels: Level1 Level2 Level3 Level4 Level6 Level7 NA x9<-factor(c("Level1","Level2","Level3","Level4","NA","Level6","Level7",NA)) x9 [1] Level1 Level2 Level3 Level4 NA Level6 Level7 <NA> Levels: Level1 Level2 Level3 Level4 Level6 Level7 NA x10<-factor(c("Level1","Level2","Level3","Level4","Level6","Level7",NA)) x10 [1] Level1 Level2 Level3 Level4 Level6 Level7 <NA> Levels: Level1 Level2 Level3 Level4 Level6 Level7 x11<-c(1,2,3,4,"NA") x11 [1] "1" "2" "3" "4" "NA" is.numeric(x11) [1] FALSE x12<-c(1,2,3,4,NA) x12 [1] 1 2 3 4 NA is.numeric(x12) [1] TRUE
- Related Questions & Answers
- What is the difference between HTML tags <div> and <span>?
- What is the difference between the != and <> operators in Python?
- What is the difference between <jsp:forward page = ... > and response.sendRedirect(url)?
- What is the difference between static_cast<> and C style casting?
- What is difference between <button> vs. <input type="button" />?
- What is the difference between >> and >>> operators in Java?
- Difference Between MySql <> NULL and IS NOT NULL?
- How to find the column mean by excluding NA’s and if all values are NA then output NA in R data frame?
- What is the difference between #include <filename> and #include “filename”?
- Why Naïve Bayesian is classifications called Naïve?
- What is the difference between $ and @ in R?
- What are the >> and << operators in Python?
- How to convert NA’s in sequence to a single NA in an R vector?
- What is the difference between the dot (.) operator and -> in C++?
- Difference between <ion-list> and <div class=“list”> in Ionic framework?
Advertisements