- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove question mark from corrplot in R?
When we have NAs present in the data frame or matrix then correlation matrix contains NA values. Now if we create the correlation matrix plot using corrplot function the Output display question marks.
If we want to create the correlation matrix without question marks then we can use the na.label argument and set it to blank as shown in the below Example.
Example
Following snippet creates a sample matrix −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4) M
The following matrix is created −
[,1] [,2] [,3] [,4] [1,] 3 2 5 NA [2,] NA NA 5 2 [3,] NA 2 5 2 [4,] 3 2 NA 2
To remove the question mark from the corrplot in R, on the above created data frame, add the following code to the above snippet −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4) M_corr<-cor(M) M_corr
Output
If you execute all the above given snippets as a single program, it generates the following Output −
[,1] [,2] [,3] [,4] [1,] 1 NA NA NA [2,] NA 1 NA NA [3,] NA NA 1 NA [4,] NA NA NA 1
To remove the question mark from the corrplot in R, on the above created data frame, add the following code to the above snippet −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4) M_corr<-cor(M) corrplot(M_corr)
Output
If you execute all the above given snippets as a single program, it generates the following Output −
To remove the question mark from the corrplot in R, on the above created data frame, add the following code to the above snippet −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4) M_corr<-cor(M) corrplot(M_corr,na.label=" ")
Output
If you execute all the above given snippets as a single program, it generates the following Output −
We can also replace question mark with NA as shown below −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4) M_corr<-cor(M) corrplot(M_corr,na.label="NA")
Output
If you execute all the above given snippets as a single program, it generates the following Output −
- Related Articles
- How to plot matrix elements using corrplot in R?
- How to change the color code of corrplot in R?
- How to disable the display of some correlations using corrplot in R?
- Which number should replace the question mark?
- How to remove NULL values from a list in R?
- How to remove names from a named vector in R?
- How to remove end lines from a boxplot in R?
- How to remove duplicate columns from a matrix in R?
- How to remove line numbers from data.table object in R?
- What does double question mark (??) operator mean in PHP ?
- How to remove interaction from regression model in stargazer in R?
- How to remove option bar from ggplotly using R?
- How to remove border of bars from histogram in base R?
- How to remove a particular value from a vector in R?
- How to remove first few rows from each group in R?
