R Programming Questions and Answers – Functions – 8

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

Answer: b
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

Answer: c
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

Answer: a
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.
advertisement
advertisement

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

Answer: a
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

Answer: a
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.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: b
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

Answer: c
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.
advertisement

8. What will be the output of runif()?
a) Random number
b) Numbers
c) Character
d) Path generation
View Answer

Answer: a
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

Answer: a
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.
advertisement

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

Answer: b
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

Answer: a
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

Answer: b
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

Answer: a
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

Answer: b
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

Answer: a
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 Books in R Programming Language .

To practice all areas of R Programming Language, Here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.