Skip to content

R Frequently Asked Questions

Statistical Computing and Graphics in R

Menu
  • Learn R
    • R Basics
      • R FAQS about Package
      • R GUI
      • Using R packages
      • Missing Values
    • R Graphics
    • Data Structure
      • Data Frame
      • Matrices
      • List
    • R Programming
    • Statistical Models
  • R Quiz
    • MCQs R Programming
    • R Basic Quiz 7
    • MCQs R Debugging 6
    • MCQs R Vectors 5
    • R History & Basics 4
    • R Language Test 3
    • R Language MCQs 2
    • R Language MCQs 1
  • MCQs
    • MCQs Statistics
      • MCQs Basic Statistics
      • MCQs Probability
      • MCQs Graph & Charts
      • MCQs Sampling
      • MCQs Inference
      • MCQs Correlation & Regression
      • MCQs Time Series
      • MCQs Index Numbers
      • MCQs Quality Control 1
    • MCQS Computer
    • MCQs Mathematics Part-I
  • About ME
  • Contact Us
  • Glossary

Category: Missing Values

R FAQ missing values. Frequently Asked Questions about missing values

Handling Missing values in R

No Comments
| Missing Values

Question: What are the differences between missing values in R and other Statistical Packages?

Answer: Missing values (NA) cannot be used in comparisons, as already discussed in the previous post on missing values in R. In other statistical packages (software) a “missing value” is assigned some code either very high or very low in magnitude such as 99 or -99 etc. These coded values are considered as missing and can be used to compare to other values and other values can be compared to missing values. In R language NA values are used for all kinds of missing data, while in other packages, missing strings and missing numbers are represented differently, for example, empty quotations for strings, and periods, large or small numbers. Similarly, non-NA values cannot be interpreted as missing while in other packages system missing values are designate from other values.

Question: What are NA options in R?

Answer: In the previous post on missing values, I introduced is.na() function as a tool for both finding and creating missing values. The is.na() is one of several functions build around NA. Most of the other functions for missing values (NA) are options for na.action(). The possible na.action() settings within R are:

    • na.omit() and na.exclude(): These functions return the object with observations removed if they contain any missing (NA) values. The difference between these two functions na.omit() and na.exclude() can be seen in some prediction and residual functions.
    • na.pass(): This function returns the object unchanged.
    • na.fail(): This function returns the object only if it contains no missing values.

To understand these NA options use the following lines of code.

> getOption(“na.action”)
> (m<-as.data.frame(matrix(c(1 : 5, NA), ncol=2)))
> na.omit(m)
> na.exclude(m)
> na.fail(m)
> na.pass(m)

Note that it is wise to both investigate the missing values in your data set and also make use of the help files for all functions you are willing to use for handling missing values. You should be either aware of and comfortable with the default treatments (handling) of missing values or specifying the treatment of missing values you want for your analysis.

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Skype
  • Tumblr
  • Pinterest
  • Print
  • WhatsApp
  • Telegram
  • Reddit
  • Pocket

Like this:

Like Loading...

Read More »

Missing values In R

No Comments
| Missing Values

Question: Can missing values be handled on R?
Answer: Yes, in R language one can handle missing values. The way of dealing with missing values is different as compared to other statistical software such as SPSS, SAS, STATA, EVIEWS etc.

Question: What is the representation of missing values in R Language?
Answer: In R missing values or data appears as NA. Note that NA is not a string nor a numeric value.

Question: Can R user introduce missing value(s) in matrix/ vector?
Answer: Yes user of R can create (introduce) missing values in vector/ Matrix. For example,

> x <- c(1,2,3,4,NA,6,7,8,9,10)
> y <- c(“a”, “b”, “c”, NA, “NA”)

Note that on y vector the fifth value of strong “NA” not a missing value.

Question: How one can check that there is missing value in a vector/ Matrix?
Answer: To check which values in a matrix/vector recognized as missing value by R language, use the is.na function. This function will return a vector of TRUE or FALSE. TRUE indicates that the value at that index is missing while FALSE indicates that the value is not a missing value. For example

> is.na(x)    # 5th will appear as TRUE while all other will be FALSE
> is.na(y)    # 4th will be true while all others as FALSE

Note that “NA” in the second vector is not a missing value, therefore is.na will return FALSE for this value.

Question: In R language, can missing values be used comparisons?
Answer: No missing values in R cannot be used in comparisons. NA (missing values) is used for all kinds of missing data. Vector x is numeric and vector y is a character object. So Non-NA values cannot be interpreted as missing values. Write the command, to understand it

x < 0
y == NA
is.na(x) <- which(x–7); x1

Question: Provide an example for introducing NA in the matrix?
Answer: Following command will create a matrix with all of the elements as NA.

> matrix(NA, nrow = 3, ncol = 3)
> matrix(c(NA,1,2,3,4,5,6,NA, NA), nrow = 3, ncol = 3)

For further detail how to deal with missing values in R visit: Missing Values in R

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Skype
  • Tumblr
  • Pinterest
  • Print
  • WhatsApp
  • Telegram
  • Reddit
  • Pocket

Like this:

Like Loading...

Read More »

Subscribe via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 257 other subscribers

Search Form

Facebook

Facebook

Categories

  • Advance R Programming (3)
  • Data Analysis (10)
    • Comparisons Tests (2)
    • Statistical Models (8)
  • Data Structure (9)
    • Data Frame (2)
    • Factors in R (1)
    • List (2)
    • Matrices (2)
    • Vectors in R (1)
  • Importing/ Exporting Data (4)
    • R Data Library (4)
  • R Control Structure (3)
    • For loop in R (1)
    • Switch Statement (1)
  • R FAQS (18)
    • Missing Values (2)
    • R Basics (12)
    • R FAQS about Package (3)
    • R Programming (2)
  • R Graphics (4)
    • Exploring Data in R (1)
    • plot Function (2)
  • R Language Basics (4)
  • R Language Quiz (8)
  • Using R packages (2)
https://www.youtube.com/watch?v=MZpiMyAfnYQ&list=PLB01qg3XnNiMbKkvP2wYzzHkv6ZekaKZx

Posts: itfeature.com: Basic Statistics and Data Analysis

MCQs Time Series Analysis 5

An Introduction to the Pakistan Bureau of Statistics

Prepared by: Dr. Abdul Majid, Statistical Officer, Pakistan Bureau of Statistics, Regional Office Multan. Introduction (Pakistan Bureau of Statistics) Pakistan Bureau of Statistics (PBS) is the prime official agency of Pakistan. It is responsible…

Multiple Linear Regression Models

A wide scatter of points around the regression line shows that there is still room for further improvement. Including extra variables in the model will map up some of the residual variability remaining after…

MCQs Estimation Quiz 7

MCQs from Statistical Inference cover the topics of Estimation and Hypothesis Testing for the preparation of exams and different statistical job tests in Government/ Semi-Government or Private Organization sectors. These tests are also helpful…

Job Interview: Recently Asked Questions

Following are different Job Interview questions asked in interviews related to Jobs of Statistical Officer, Data Analysts, Lecturer in Statistics, Enumerator, etc. These questions are also useful for job interviews related to different disciplines….

Posts: gmstat.com: GM Statistics

MCQs Econometrics Quiz 5

This quiz is about Econometrics, which covers the topics of Regression analysis, correlation, dummy variable, multicollinearity, heteroscedasticity, autocorrelation, and many other topics. Let’s start with MCQs Econometrics test An application of different statistical methods applied to the economic data used…

MCQs Computer Programming – 1

The Quiz is about MCQs of Computer Programing and Programming languages. Take another Quiz bout Application Software If you Found that the Above POSTED MCQ is/ are WRONGPLEASE COMMENT below The MCQ with the CORRECT ANSWER and its DETAILED EXPLANATION.

Islamic Quiz – 2

Islamic Quiz for PPSC Lecturer Test Perform another Quiz about Islamic Quiz 1 If you Found that the Above POSTED MCQ is/ are WRONGPLEASE COMMENT below The MCQ with the CORRECT ANSWER and its DETAILED EXPLANATION.

Islamic Quiz – 1

Islamic Quiz for PPSC Lecturer Test Perform another Quiz about Computer If you Found that the Above POSTED MCQ is/ are WRONGPLEASE COMMENT below The MCQ with the CORRECT ANSWER and its DETAILED EXPLANATION.

MCQs Computer Basics 4

This quiz is about MCQS computer Basics. The greatest scientists of their era, Abu Jaffar Muhammad Ibn Musa Al-Khawarizmi (780-850), Alan Mathison Turing (1912-1954), and John Von Neuman (1903-1957) took part in the invention of computers. A mathematician and a…

R Frequently Asked Questions 2022 . Powered by WordPress

%d bloggers like this:
    pixel