## Objective

As we have already discussed **R** in deep in our previous blogs. Now in this respective blog, we will provide you 30 frequently asked R interview questions and answers including advanced terminologies to advanced long answers. These questions will definitely help you to sort out your each and every small concept.

## Top 30 R Interview Questions and Answers for Freshers and Experienced

**Q.1. Explain how you can start the R commander GUI?**

rcmdr command is used to start the R Commander GUI. Once R is running, simply loading the Rcmdr package by typing the command library(Rcmdr) into the R Console starts the R Commander graphical user interface.

Read more about R Commander GUI.

**Q.2. What is object-oriented programming in R?**

Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A feature of objects is that an object’s procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of “this” or “self”)

Read more about object-Oriented Programming in R.

**Q.3. 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.

Learn more about R Procedural Programming.

**Q.4. What are statistical software and data analysis in R?**

R is an open source programming language and software environment for statistical computing and graphics that is supported by the R Foundation for Statistical Computing. The R language is widely used among statisticians and data miners for developing statistical software and data analysis.

**Q.5. What are various steps involved in Analytics project in R?**

- Understand the business problem.
- Explore the data and become familiar with it.
- Prepare the data for modeling by detecting outliers, treating missing values, transforming variables, etc.
- After data preparation, start running the model, analyze the result and tweak the approach. This is an iterative.
- Validate the model using a new data set.
- Start implementing the model and track the result to analyze the performance of the model over the period of time.

**Q.6. What is 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).

**Q.7. What is Mean in R?**

The mean is the average of the numbers: a calculated “central” value of a set of numbers.

To calculate: Just add up all the numbers, then divide by how many numbers there are.

**Q.8. What is Median in R?**

The Median is the “middle” of a sorted list of numbers. BUT, with an even amount of numbers, things are slightly different. In that case, we find the middle pair of numbers, and then find the value that is halfway between them. This is easily done by adding them together and dividing by two.

**Q.9. What is Variance in R?**

The Variance is defined as the average of the squared differences from the Mean.

**Q.10. What is polynomial in R?**

Polynomial comes from **poly**– (meaning “many”) and **nomial-** (in this case meaning “term”) … so it says “many terms”.

**Q.11. What is the recycling of elements in a vector? Give an example.**

When two vectors of different length are involved in an operation then the elements of the shorter vector are reused to complete the operation. This is called element recycling.

Example – v1 <- c(4,1,0,6) and V2 <- c(2,4) then v1*v2 gives (8,4,0,24). The elements 2 and 4 are repeated.

Read more about R Vector in detail.

**Q.12. What is factor variable in R language?**

Factor variables are categorical variables that hold either string or numeric values. Factor variables are used in various types of graphics and particularly for statistical modeling where the correct number of degrees of freedom is assigned to them.

Read more about R factors in detail.

**Q.13. What is the difference between the data frame and a matrix in R?**

Data frame can contain heterogeneous inputs while a matrix cannot. In the matrix, only similar data types can be stored whereas in a data frame there can be different data types like characters, integers or other data frames.

**Q.14. What are the data types in R on which binary operators can be applied?**

Scalars, Matrices, and Vectors

Read more about R Data Types in detail.

**Q.15. What is the ****function in R?**

Many of the functions in R are actually functions of functions. Objects in the function are local to the function. The object can be returned any data type.

Read more about R Programming Functions in detail.

**Q.16. What is attribute function in R? **

To get or set a single attribute, you can use the attr() function. This function takes two important arguments. The first argument is the object we want to examine, and the second argument is the name of the attribute we want to see or change. If the attribute we ask for doesn’t exist, R simply returns NULL.

**Q.17. What is length function in R?**

R length Function.** length()** function gets or sets the length of a vector (list) or other objects. length() function can be used for all R objects. For an environment, it returns the object number in it. NULL returns 0.

**Q.18. What is Data Structure in R?**

A data structure is a specialized format for organizing and storing data. General data structure types include the array, the file, the record, the table, the tree, and so on. Any data structure is designed to organize data to suit a specific purpose so that it can be accessed and worked with in appropriate ways

**Q.19. What is a** **file in R?**

R is a file extension for a script written in R. R is a programming language designed for statistical computing and graphics purposes. Contains code that can be executed within the R software environment

**Q.20. What is an arbitrary function in R?**

Arbitrary function means any function. But generally, it refers to a function belongs to the same class of functions we are discussing ( its freedom is limited ). For example, when talking about continuous real-valued functions defined on the bounded closed interval of the real line, by an arbitrary function may refer to a function of the same type.

**Q.21. What is the table in R?**

An arbitrary R object, or an object inheriting from class “table” for the as.data.frame method. … a character vector giving the row names for the data frame. responseName. The name to be used for the column of table entries, usually counts.

**Q.22. What is the tree in R?**

R-trees are tree data structures used for spatial access methods, i.e., for indexing multi-dimensional information such as geographical coordinates, rectangles or polygons. The R-tree was proposed by Antonin Guttman in 1984 and has found significant use in both theoretical and applied contexts.

**Q.23. Explain if control statements in R?**

if If this condition is true, then carry out a certain task. R makes it even easier: You can drop the word then and specify your choice in an if statement. See the code syntax below for if statement:

if (test_expression) {

statement

}

For Example:

x <- 1:15 if (sample(x, 1) <= 10) { print("x is less than 10")

Read more about Control Statements in R.

**Q.24. What is scan() in R?**

Read Data Values: Read data into a vector or list from the console or file.

Keywords: File, connection

For Example:

> z <- scan() 1: 12 5 3: 2 4: Read 3 items > z [1] 12 5 2

Read more about Input Output features in R.

**Q.25. What are packages in R?**

R – Packages. R packages are a collection of R functions, complied code and sample data. They are stored in a directory called “library” in the R environment. By default, R installs a set of packages during installation.

Read more about R Packages in detail.

**Q.26. What is readline() in R?**

Read Text Lines from a Connection: Read some or all text lines from a connection.

Keywords: File, connection

We can use readline() for inputting a line from the keyboard in the form of a string:

For Example:

> w <- readline() xyz vw u > w [1] "xyz vw u"

Read more about Input Output features in R.

**Q.27. What is a Dataframe in R?**

A data frame is a list of vectors, factors, and/or matrices all having the same length (number of rows in the case of matrices).

Read more about R Data Frame in detail.

**Q.28. What is function in R?**

In fact, many of the functions in R are actually functions of functions. … Objects in the function are local to the function. The object returned can be any data type

Read more about R functions in detail.

**Q.29. What is a** **loop in R?**

A loop is a way to repeat a sequence of instructions under certain conditions. They allow us to automate parts of our code that are in need of repetition.

Read more about R loops in detail.

**Q.30. What is JIT?**

JIT stands for just-in-time compiler.It is a method to improve the run-time performance of computer programs.

Follow this link to read more Interview Questions of R Programming Language.