R Programming Quiz 19

The Quiz is about R Programming Quiz with Answers. There are 20 multiple-choice questions covering different topics related to R Language Programming. Let us start with the R Programming Quiz now.

Online R Programming Quiz with Answers

Please enter your email:

1. For a matrix $X$ of order $n\times p$ and a vector $Y$ of order $n\times 1$, one can find regression coefficients using

 
 
 
 

2. All columns in a matrix must have the

 
 
 
 

3. In R, what is the result of the function as.integer(3.3)?

 
 
 
 

4. In R, which command removes a variable from memory?

 
 
 
 

5. Assume the array books_array contains 6 elements. The array has three rows and two columns and appears as follows:

     [,1]              [,2]
[1,] "It"              "Dr. Sleep"
[2,] "Misery"          "Carrie"
[3,] "The Shining"     "The Mist"

Which of the following commands will return “The Shining”?

 
 
 
 

6. What is the main reason for using the R language?

 
 
 
 

7. What is the first step you must take before you can read an Excel spreadsheet in R?

 
 
 
 

8. To perform a one-way Analysis of variance, one can use a function

 
 
 
 

9. How many elements will be in vector $b$, if b <- 10:15

 
 
 
 

10. In R, which command will output the data from the Nile built-in data set?

 
 
 
 

11. In R, which command should you use to insert a new row into a data frame?

 
 
 
 

12. Assume that the function add is defined as follows:

add <- function(x,y) {
(x + y)
return (x - y)
temp <<- (x * y)
return (x / y)
}

What will be the output if you issue the command add(10,5)?

 
 
 
 

13. Which command in R would return the following character vector? “Imdad” “Usman” “Ali” “Amir”

 
 
 
 

14. In R, assume you have a vector named “age,” and each element in the vector is the age of one person in a group. Which command must you use to reorder the ages from youngest to oldest?

 
 
 
 

15. In R, what is the result of the function as.numeric(TRUE)?

 
 
 
 

16. In R, variables are typically assigned using <-, but they can also be assigned using which of the following symbols?

 
 
 
 

17. After installing and calling the httr library in R, which method should you use to update a resource?

 
 
 
 

18. In R, assume you have a vector named “age,” and each element in the vector is the age of one person in a group. The vector has the following content: 24 32 46 19. What will be the result if you issue the age[-2] command?

 
 
 
 

19. In R language, which command returns the last six elements of a data object such as a data frame?

 
 
 
 

20. In R, assume a character vector called “names” has the following contents:

“Harry” “Jimmy” “Tammy”

Which command would return the following logical vector?

FALSE TRUE FALSE

 
 
 
 

Online R Programming Quiz with Answers

  • What is the main reason for using the R language?
  • In R, what is the result of the function as.numeric(TRUE)?
  • In R, variables are typically assigned using <-, but they can also be assigned using which of the following symbols?
  • Which command in R would return the following character vector? “Imdad” “Usman” “Ali” “Amir”
  • In R, assume you have a vector named “age,” and each element in the vector is the age of one person in a group. The vector has the following content: 24 32 46 19. What will be the result if you issue the age[-2] command?
  • Assume the array books_array contains 6 elements. The array has three rows and two columns and appears as follows:

    [,1]              [,2]
[1,] “It”              “Dr. Sleep”
[2,] “Misery”          “Carrie”
[3,] “The Shining”   “The Mist”

Which of the following commands will return “The Shining”?

  • In R language, which command returns the last six elements of a data object such as a data frame?
  • Assume that the function add is defined as follows:
    add <- function(x,y) {
    (x + y)
    return (x – y)
    temp <<- (x * y)
    return (x / y)
    }
    What will be the output if you issue the command add(10,5)?
  • What is the first step you must take before you can read an Excel spreadsheet in R?
  • After installing and calling the httr library in R, which method should you use to update a resource?
  • In R, what is the result of the function as.integer(3.3)?
  • In R, which command removes a variable from memory?
  • In R, assume a character vector called “names” has the following contents: “Harry” “Jimmy” “Tammy” Which command would return the following logical vector? FALSE TRUE FALSE
  • In R, assume you have a vector named “age,” and each element in the vector is the age of one person in a group. Which command must you use to reorder the ages from youngest to oldest?
  • In R, which command will output the data from the Nile built-in data set?
  • In R, which command should you use to insert a new row into a data frame?
  • To perform a one-way Analysis of variance, one can use a function
  • How many elements will be in vector $b$, if b <- 10:15
  • All columns in a matrix must have the
  • For a matrix $X$ of order $n\times p$ and a vector $Y$ of order $n\times 1$, one can find regression coefficients using
R Programming Quiz with Answrs

Statistics and Data Analysis

Online Quiz and Test Website

Questions Data Types in R 2025

This post is about Data Types in R language. It contains Interview Questions about Data Types. It contains some basic questions that are usually asked in job interviews and examinations vivas.

What are R data types?

In programming languages, a data type is a classification that specifies what type of a value variable can have. It also describes what type of relational, mathematical, and logical operations can be applied to it without causing an error. We need to use various variables to store information while coding in any programming language. Variables are nothing but reserved memory locations to store values. This means that when one creates a variable one reserves some space in memory. The variables are assigned with R-Objects. Thus, the data type of the R-object becomes the data type of the variable.

How Many Data Types in R Language?

There are 5 types of data types in R language, namely

  • Integer data type
  • Numeric data type
  • Character data type
  • Complex data type
  • Logical data type

What are the Data Types in R on Which Binary Operators Can Be Applied?

The binary operators can be applied to the data types (i) Scalars, (ii) Matrices, and (iii) Vectors.

What are the Types of Objects in R?

There are 6 types of objects in the R Language.

  • Vectors are the most important data type of object in R. A vector is a sequence of data elements having the same data type.
  • Matrices (and arrays) that are multi-dimensional generalizations of vectors. Matrices are arranged into a fixed number of rows and columns. The matrices (or arrays) are vectors that can be indexed by two or more indices and will be printed in special ways.
  • Factors provide compact ways to handle categorical data.
  • Lists are a general form of vector in which the various elements need not be of the same type and are often themselves vectors or lists. Lists provide a convenient way to return the results of a statistical computation.
  • Data frames are matrix-like (tabular data objects) structures, in which the columns can be of different types. Think of data frames as ‘data matrices’ with one row per observational unit but with (possibly) both numerical and categorical variables. Many experiments are best described by data frames.
  • Functions are themselves objects in R language which can be stored in the project’s workspace. Functions provide a simple and convenient way to extend R.

Note that vector, matrix, and array are of a homogenous type and the other two list and data frames are of heterogeneous type.

What is the difference between a Data Frame and a Matrix in R Language?

In R language data frame may contain heterogeneous data while a matrix cannot. Matrix in R stores only similar data types while data frame can be of different data types like characters, integers, or other data types.

What is the Factor Variable in R language?

In language, Factor variables are categorical (qualitative) variables that can have either string or numeric values. Factor variables are used in various types of graphics, particularly for statistical modeling where the correct number of degrees of freedom is assigned to them.

What is an Atomic Vector and How Many Types of Atomic Vectors are in R?

The atomic vector is the simplest data type in R. Atomic vectors are linear vectors of a single primitive type. There are four types of atomic vectors are present in R:

  • Numerical
  • Integer
  • Character
  • Logical
Data Types in R Language Interview Questions

Online Quiz Website

Statistics and Data Analysis

Packages in R for Data Analysis 2025

The post is about “Packages in R for Data Analysis”. It is the form of Questions and Answers. The Questions and answers about “Packages in R for Data analysis” describe a short description or function of the R Packages.

What are R Packages? (or What are Packages in R?)

Packages in R are the collections of sample data, R functions, and compiled code in a well-defined format and these packages are stored in a directory called ‘library’ in the R environment. One of the strengths of R is the user-written function in R language. By default, R installs a standard set of packages during installation. Other R packages are available for download and installation. Once R packages are installed, they have to be loaded into the session to be used.

What is Procedural Programming in R?

Procedural programming is a programming paradigm, derived from structured programming, based on the concept of the procedure call. Procedures, also known as routines, subroutines, or functions (not to be confused with mathematical functions, but similar to those used in functional programming), simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program’s execution, including by other procedures or itself.

What is a Compiler in R?

A compiler is computer software that transforms computer code written in one programming language (the source language) into another computer language (the target language).

Define MATLAB Package

The MATLAB package includes wrapper functions and variables. Also, these functions are used to replicate Matlab function calls.

Differentiate between library() and require() Functions in R Language

The following are the differences between library() and require() functions in R language.

library()require()
The library() function gives an error message, if the desired package cannot be loaded.The require() function is used inside the function and throws warning messages whenever a particular package is not found.
The library() package loads the packages whether it is already loaded or not.It just checks that it is loaded, or loads it if it is not (used in functions that rely on a certain package). The documentation explicitly states that neither function will reload an already loaded package.

Consider a related R code example for the above differentiation:

## Example for loading single R Package

## library() function
library(mctest, character.only = TRUE)

## require() function
if(!require(mctest, character.only = TRUE, quietly = TRUE)){
  install.packages(package)
}

## OR

if(!require(mctest, character.only = TRUE, quietly = TRUE)){
  install.packages(mctest)
  library(mctest, character.only = TRUE)
}
## Example for loading multiple R Package
for (package in c(", ")){
  if(!require(package, character.only = TRUE, quietly = TRUE)){
    install.packages(package)
    library(package, character.only = TRUE)
    }
}
Packages in R for Data Analysis

Which Packages are used for Exporting the Data in R?

    There are many ways (packages or methods to export the data into another format like SPSS, SAS, Stata, or Excel Spreadsheet. For Excel use the package xlsReadWrite and for SAD, SPSS, and STATA use foreign the package.

    What is the Use of the coin Package in R?

      The coin package is used to achieve the re-randomization or permutation-based statistical tests.

      Why vcd package is used?

      The vcd package provides different methods for visualizing multivariate categorical data.

      What is the Use of the lattice Package?

      The lattice package is to improve on base R graphics by giving better defaults and it can easily display multivariate relationships.

      Why library() function is used?

      The library() function is used to show the packages which are installed.

      What is the Use of the doBY Package?

      The doBy is used to define the desired table using function and model formula.

      Define the relaimpo Package.

      The relaimpo is used to measure the relative importance of each of the predictors in the model.

      Why the Package car is Used?

      The car provide a variety of regression including scatter plots, and variable plots and it also enhances diagnostic.

      Define the robust Package.

      The robust provides a library of robust methods including regression.

      In which R package Survival Analysis is Defined?

      The survival analysis is defined under the R package named survival.

      What is the use of the MASS Package?

      The MASS package in R language includes those functions that perform linear and quadratic discriminant function analysis.

      What is the use of the forecast Package?

      The forecast provides the functions that are used for the automatic selection of ARIMA and exponential models.

      What is the Use of the party Package?

      The party is used to provide a non-parametric regression for ordinal, nominal, censored, and multivariate responses.

      Which Package provides the Bootstrapping?

      The boot package is used which provides bootstrapping.

      What is the Use of the Matrix Package?

      The Matrix package includes those functions that support sparse and dense matrices like Lapack, BLAS, etc.

      What is the iPlots?

      The iPlots is a package that provides bar plots, and mosaic plots. Also, it provides box plots, parallel plots, scatter plots, and histograms.

      Which Package is Used for Power Analysis in R?

      The Pwr package is used for power analysis in R.

      What is the npmc?

      The npmc is a package that gives nonparametric multiple comparisons.

      Online MCQs and Quiz website

      Packages in R For Data Analysis: Frequently Asked Questions About R