Question

A missing value in R is denoted by NA.

use R studio

 A missing value in R is denoted by NA.

 Missing values are different from other values in R in two ways:

 1. Any computation involving a missing value will return a missing value.

 2. The is.na function will return TRUE if a value is missing and FALSE otherwise.

 a) Enter the following code into RStudio.

 > x <- c (1, 4, 7, NA, 12, 19,15, 21, 20)

 b) Add an appropriate comment to the above code.

 Try to find the mean of x.

 d) Use is.na to determine if there are missing values.

 Add na. rm=TRUE to mean (x) remove missing values.



3 0
Add a comment Improve this question Transcribed image text
Answer #1

> # Q(a)

> x<-c(1,4,7,NA,12,19,15,21,20)
> # A vector x with NA's in it--Q(b)

> # Q(c)
> mean(x)
[1] NA

># Q(d)
> is.na(x)
[1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE
[8] FALSE FALSE
> # Q(e)
> mean(x,na.rm = T)
[1] 12.375

Add a comment
Know the answer?
Add Answer to:
A missing value in R is denoted by NA.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the R code and result in Rstudio or R 1. Define a character vector...

    What is the R code and result in Rstudio or R 1. Define a character vector in R as follows: y - c("a, "bc", "def") a. Report the output of the following function: length(y);y"a;y"b" b. nchar(x) takes a character vector x as an argument and returns a vector whose elements contain the sizes of the corresponding elements of x. Report the output of nchar(y) 2. Define a numeric vector in R as follows: z=c(3,7,1,2) a. Report the output of the...

  • How to apply "na.omit" or other ways in R Markdown to remove missing value for csv...

    How to apply "na.omit" or other ways in R Markdown to remove missing value for csv data file in R? Please attach example code here thank you.

  • Python 3: Write a LinkedList method named contains, that takes a value as a parameter and...

    Python 3: Write a LinkedList method named contains, that takes a value as a parameter and returns True if that value is in the linked list, but returns False otherwise. class Node: """ Represents a node in a linked list """ def __init__(self, data): self.data = data self.next = None class LinkedList: """ A linked list implementation of the List ADT """ def __init__(self): self.head = None def add(self, val): """ Adds a node containing val to the linked list...

  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • Question is two parts In R(Programming language). Define and write a function which takes one number...

    Question is two parts In R(Programming language). Define and write a function which takes one number as input and detects whether the number is even. Return TRUE if it is even, and FALSE otherwise. You need to first detect if the input is an integer; if not, return NA. Note 1: TRUE and FALSE are logical values, not strings! Note 2: No need to get user input from the console. Test your function using your_function_name(1), your_function_name(2), and your_function_name(1.5). Hint: What...

  • I am supposed to answer these questions using R software. However, I have little to no experience...

    I am supposed to answer these questions using R software. However, I have little to no experience with R or any other type of programming. Can someone please help me with the R code for these questions? Q1. Suppose you have a population of size 5 [ie. N= corresponding numbers are: You measure sorne quantity (X) and the 21,22,23, 24,25 a) Calculate the population mean () b) Calculate the population variance (ơ2) using the formula ơ2-41 -P Q2. Imagine you...

  • Using the following definition (List.h file) for a list, implement the member functions (methods) for the...

    Using the following definition (List.h file) for a list, implement the member functions (methods) for the List class and store the implementation in a List.cpp file. Use a doubly linked list to implement the list. Write the client code (the main method and other non-class methods) and put in file driver.cpp. file: List.h typedef int ElementType; class node{ ​ElementType data; ​node * next; node* prev; }; class List { public: List(); //Create an empty list bool Empty(); // return true...

  • COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree:    class treeNode: def __init__(self, value, lchild, rchild):...

    COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree:    class treeNode: def __init__(self, value, lchild, rchild): self.value, self.lchild, self.rchild = value, lchild, rchild def __init__(self): self.treeRoot = None    #utility functions for constructTree def mask(self, s): nestLevel = 0 masked = list(s) for i in range(len(s)): if s[i]==")": nestLevel -=1 elif s[i]=="(": nestLevel += 1 if nestLevel>0 and not (s[i]=="(" and nestLevel==1): masked[i]=" " return "".join(masked) def isNumber(self, expr): mys=s.strip() if len(mys)==0 or not isinstance(mys, str): print("type mismatch error: isNumber")...

  • I would like the whole Question done on r studio with the R Code. 1. In...

    I would like the whole Question done on r studio with the R Code. 1. In this question we will evaluate type I and type II error probabilities for one-sided tests. We will consider normally distributed data, with unit variance and independent obervations. We will use Ho : μ-0 for the null and H1 : μ-1 for the alternative, unless otherwise stated. (a) Suppose we have n-6 observationsx. What is the sampling distribution of the (10 marks) sample mean (that...

  • Are based on the following Queue class code segment class QueueFull {/* Empty exception class */};...

    Are based on the following Queue class code segment class QueueFull {/* Empty exception class */}; Class Queue Empty {/* Empty exception class */}; struct Node//Node structure int data;//Holds an integer Node* next;//Pointer to next node in the queue}; Class Queue//Linked node implementation of Queue ADT {Private: Node* front;//Pointer to front node of queue Node* rear;//pointer to last node of queue Public: Queue ()://default constructor initializes queue to be empty -Queue ();//Deallocates all nodes in the queue Void Add (int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT