0% found this document useful (0 votes)
21 views4 pages

Essential R Functions and Concepts

The document contains a series of multiple-choice questions and answers related to R programming. Topics covered include reading and writing CSV and Excel files, type conversion, package management, conditional execution, and looping structures in R. Each question is followed by the correct answer, providing a quick reference for R programming concepts.

Uploaded by

Jeya preetha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Essential R Functions and Concepts

The document contains a series of multiple-choice questions and answers related to R programming. Topics covered include reading and writing CSV and Excel files, type conversion, package management, conditional execution, and looping structures in R. Each question is followed by the correct answer, providing a quick reference for R programming concepts.

Uploaded by

Jeya preetha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Which function is used to read a CSV file in R?

A) [Link]() B) [Link]() C) [Link]() D) [Link]() Answer: D

2. What does the getwd() function do in R?


A) Sets the working directory B) Prints the working directory
C) Gets the current working directory D) Changes the working directory Answer: C

3. Which package is required to read Excel files in R?


A) openxlsx B) readxl C) xlsx D) excelR Answer: B

4. What is the default value of the header parameter in [Link]()?


A) NULL B) FALSE C) 1 D) TRUE Answer: D

5. Which function is used to write data to a CSV file in R?


A) [Link]() B) [Link]() C) [Link]() D) [Link]() Answer: A

6. What does JSON stand for?


A) Java Object Notation B) Java Standard Object Notation C) JavaScript Object Notation
D) JavaScript Open Notation Answer: C

7. Which function is used to merge two data frames in R?


A) concat() B) join() C) merge() D) combine() Answer: C

8. What is the purpose of the [Link]() function?


A) To create a new data frame B) To read data from a text file C) To modify a data frame
D) To export data to a text file Answer: D

9. Which function is used to calculate the average salary for each department?
A) summary() B) tapply() C) mean() D) aggregate() Answer: D

10. What is the correct way to set a new working directory in R?


A) changewd(...) B) [Link](...) C) set_directory(...) D) setwd(...) Answer: D
1. What does type conversion in R refer to?
A) Renaming variables B) Changing variable types C) Assigning values
D) Creating functions Answer: B

2. Which function is used to explicitly convert a value to logical type in R?


A) [Link]() B) [Link]() C) [Link]() D) [Link]() Answer: C

3. What is the result of [Link](50)?


A) FALSE B) TRUE C) NA D) 50 Answer: B

4. What is the output of [Link](FALSE) in R?


A) 0 B) 1 C) "FALSE" D) NA Answer: C

5. What does the [Link]("50") function return?


A) "50" B) 50 C) FALSE D) NA Answer: B

6. What is the result of converting TRUE to numeric using [Link](TRUE)?


A) 0 B) 1 C) TRUE D) "1" Answer: B

7. Which function is used to convert vectors to a matrix by rows?


A) cbind() B) matrix() C) rbind() D) bind_rows() Answer: C

8. What is the result of combining vectors into a matrix using cbind()?


A) Fills by row B) Fills by column C) Converts to data frame D) Converts to list
Answer: B

9. Which function is used to convert vectors to a data frame in R?


A) [Link]() B) [Link]() C) [Link]() D) rbind() Answer: A

10. What is the result of [Link](matrix(1:6, nrow = 2))?


A) 2x3 matrix B) Error C) A long vector of numbers 1 to 6 D) Data frame Answer: C
1. What is the purpose of the [Link]() function in R?
A) Load a package into R B) Update all packages
C) Remove a package D) Install a new package from CRAN Answer: D

2. Which function is used to load a package into the R session?


A) [Link]() B) library() C) [Link]() D) load() Answer: B

3. What does the [Link]() function do?


A) Deletes R installation B) Removes a specific function
C) Removes an installed package D) Updates a package Answer: C

4. Where are the majority of R packages hosted?


A) GitHub B) CRAN C) SourceForge D) Stack Overflow Answer: B

5. Which repository is specifically used for bioinformatics packages in R?


A) CRAN B) GitHub C) Bioconductor D) Bitbucket Answer: C

6. What function is used to update all installed packages?


A) [Link]() B) [Link]() C) [Link]() D) [Link]()
Answer: B

7. What is the purpose of [Link]() in R?


A) List available packages online B) Load packages
C) Show all installed packages D) Remove installed packages Answer: C

8. Which function allows installing packages from GitHub?


A) [Link]() B) [Link]() C) install_github() D) library()
Answer: C

9. What keyword is used for conditional execution in R?


A) while B) for C) if D) switch Answer: C

10. What does the ifelse() function do in R?


A) Compares only single values B) Returns a data frame
C) Applies conditions to vectors D) Replaces switch() Answer: C
1. Which loop in R repeats as long as a condition is TRUE?
A) for B) while C) repeat D) loop Answer: B

2. Which R loop runs indefinitely unless explicitly stopped?


A) for B) while C) repeat D) break Answer: C

3. What is the purpose of the break statement in R loops?


A) Pause execution B) Skip an iteration C) Exit a loop D) Restart loop Answer: C

4. Which statement skips the current iteration in a loop?


A) break B) next C) exit D) continue Answer: B

5. Which loop is most suitable for iterating through a vector?


A) repeat B) while C) for D) switch Answer: C

6. What does the following code do? for (i in 1:5) { print(i) }


A) Prints even numbers only B) Loops from 0 to 5 C) Prints 1 to 5 D) Infinite loop
Answer: C

7. What does apply(X, 1, FUN) do in R?


A) Applies a function to columns B) Applies a function to rows
C) Applies to vectors D) Applies to elements Answer: B

8. Which function returns a list after applying a function to a list?


A) apply() B) sapply() C) lapply() D) mapply() Answer: C

9. Which function simplifies the result of lapply() if possible?


A) apply() B) sapply() C) tapply() D) loop() Answer: B

10. What is the use of tapply() in R?


A) Apply function to a matrix B) Grouped operations on a vector
C) Looping over elements D) Apply function to data frame rows Answer: B

You might also like