This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “Functions – 8”.

1. ________ function is usually used inside another function and throws a warning whenever a particular package is not found.

a) Dplyr

b) Require

c) Coin

d) Sample

View Answer

Explanation: Require () function is usually used inside the other function and gives a warning whenever a particular package is not found. Library () function will give an error message if the desired package is not loaded.

2. ___________ function gives an error message if the desired package cannot be loaded.

a) Dplyr

b) Require

c) Library

d) Sample

View Answer

Explanation: Library () function gives an error message if the desired package cannot be loaded. Require () function is usually used inside a function and throws a warning whenever a particular package is not found.

3. A ________________ in R programming language can also contain numeric and alphabets along with special characters like dot and underline.

a) Variable name

b) Number

c) Integer

d) Character

View Answer

Explanation: A variable name in R programming language can also contain numeric and alphabets along with special characters like a dot and underline. Variable names in R language can begin with an alphabet and also the dot symbol.

4. The current user defined objects like lists, vectors, etc. is referred to as __________ in the R language.

a) Work names

b) Work space

c) Environment

d) Console

View Answer

Explanation: The current R working environment of the user which has user defined objects like lists, vectors, etc. is referred to as Workspace in R language. The workspace of R is flexible to all functions of statistics.

5. Which function helps you perform sorting in R language?

a) Order

b) Inorder

c) Simple

d) Library

View Answer

Explanation: Order returns a permutation which rearranges its first argument into ascending and also descending order. The result of the order command is a vector where each value references to the values of the position of the object in the original data frame.

6. Which function is used to create a histogram for visualisation in R programming language?

a) Library

b) Hist

c) Data

d) Refer

View Answer

Explanation: Hist function is used to create a histogram for visualisation in R programming language. The generic function hist computes a histogram of the given data values. This function takes a vector as the input and also uses some more parameters to plot histograms.

7. Write the syntax to set the path of the current working directory in R environment?

a) Setwd(“dipath”)

b) Setwd(dir_path)

c) Setwd(“dir_path”)

d) Set(“dir_path”)

View Answer

Explanation: The current R working environment of a user which has user-defined objects like lists, vectors, etc. is referred to as Workspace in R language. The workspace of R is flexible to all functions of statistics.

8. What will be the output of runif()?

a) Random number

b) Numbers

c) Character

d) Path generation

View Answer

Explanation: Random numbers from a normal distribution can be generated using runif() function. We can specify the range of the uniform distribution with the help of max and min argument. If not provided, the default range will be between 0 and 1.

9. ________ function generates “n” normal random numbers based on the mean and standard deviation arguments passed to the function.

a) rnorm

b) vnorm

c) knorm

d) lnorm

View Answer

Explanation: rnorm function generates “n” normal random numbers based on the mean and standard deviation arguments passed to the function. The workspace of R is flexible to all functions of statistics.

10. Write a function to extract the first name in the string “Mrs. Jake Luther”?

a) Substring

b) Substr

c) Substi

d) Return

View Answer

Explanation: The substr() function gives a part of a string. The substr() method will give parts of a string, beginning at the character of the specified position, and returns the specified number of characters.

11. _________ package provides basic functionalities in R environment like arithmetic calculations, input/output.

a) R base

b) R boost

c) R serve

d) R comm

View Answer

Explanation: R Base package is the package that is loaded by default whenever the R programming environment is loaded .R base package provides basic functionalities in R environment like arithmetic calculations, input/output.

12. Which function basically finds the intersection between two different sets of data?

a) Converge

b) Merge

c) Delegate

d) Swap

View Answer

Explanation: Merge () function is used to combine two data frames and it identifies common rows or columns between the 2 data frames. Merge () function basically finds the intersection between two different sets of data.

13. Which function calculates the count of each category of a categorical variable?

a) Table

b) Intact

c) Tables

d) Retabs

View Answer

Explanation: The frequency distribution of a categorical variable can be checked using the table function in the R language. Table () function calculates the count of each category of a categorical variable.

14. The cumulative frequency distribution of a categorical variable can be checked using the ________ function in R language.

a) Sum

b) Cumsum

c) Lumpsum

d) Resum

View Answer

Explanation: The cumulative frequency distribution of a categorical variable can be checked using the cumsum () function in the R language. The frequency distribution of a categorical variable can be checked using the table function in the R language.

15. A programmer builds a _________ to avoid repeating the same task or reduce complexity.

a) Function

b) Package

c) Code

d) Console

View Answer

Explanation: A function, in a programming environment, is a set of instructions. A programmer builds a function to avoid repeating the same task or reduce complexity. A function should be written to carry out specified tasks and may or may not include arguments.

**Sanfoundry Global Education & Learning Series – R Programming Language.**

Here’s the list of Best Reference Books in R Programming Language .

__Here is complete set of 1000+ Multiple Choice Questions and Answers__.