R Language Interview Question & Answers

Our experts providing R Language interview questions & Answers/Faqs,
It can develop your carrier & knowledge to find the right job in a good MNC’s, doesn’t matter what kind of company you’re hired.

1. Explain What is R?

R is a language and environment for statistical computing and graphics. It is an open source programming language. R provides a wide variety of statistical and graphical techniques and is highly extensible. Data miners use it for developing statistical software and data analysis. One of the R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS. The R command line interface(CLI) consist of a prompt, usually the > character.

2) Explain the data import in R language.

R provides to import data in R language. To begin with the R commander GUI, user should type the commands in the command Rcmdr into the console. Data can be imported in R language in 3 ways such as:

Select the data set in the dialog box or enter the name of the data set as required.
Data is entered directly using the editor of R Commander via Data->New Data Set. This works good only when the data set is not too large.
Data can also be imported from a URL or from plain text file (ASCII), or from any statistical package or from the clipboard.

3)Why should you adopt R programming language?

R programming language is best for statistical, data analysis and machine learning. By using this language we can create objects, functions, and packages.R is an open source programming language.
By using R we can create any form of statistics and data manipulation. Furthermore, it can be used in almost every field of finance, marketing, sports etc. R Programming is extensible and hence, R groups are noted for its energetic contributions.
Lots of Rs typical features can be written in R itself and hence, R has gotten faster over time and serves as a glue language.

4)What is the best way to communicate the results of data analysis using R language?

The best possible way to do this is combine the data, code and analysis results in a single document using knitr for reproducible research. This helps others to verify the findings, add to them and engage in discussions. Reproducible research makes it easy to redo the experiments by inserting new data and applying it to a different problem.

5)How R commands are written?

By using # at the starting of the line of code like #division commands are written.

6) What is SAS and SPSS in R?

SAS stands for Statistical Analysis System. It was primarily developed to be able to analyze large quantities of agriculture data while SPSS stands for Statistical Package for the Social Sciences and was developed for the social sciences and was the first statistical programming language for the PC.

7)What are with () and BY () functions used for?

With () function is used to apply an expression for a given dataset and BY () function is used for applying a function each level of factors.

8)What is t-tests() in R?

It is used to determine that the means of two groups are equal or not by using t.test() function.

9)What is the function used for adding datasets in R?

For adding two datasets rbind() function is used but the column of two datasets must be same.

Syntax: rbind(x1,x2……) where x1,x2: vector, matrix, data frames.

10)How can you add datasets in R?

rbind () function can be used add datasets in R language provided the columns in the datasets should be same.

11)What is difference between lapply and sapply?

lapply is used to show the output in the form of list whereas sapply is used to show the output in the form of vector or data frame

12) How many types of data types are provided by R?

There are 5 types of data types present in R:

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

13)What is the difference between seq(4) and seq_along(4)?

Seq(4) means vector from 1 to 4 (c(1,2,3,4)) whereas seq_along(4) means a vector of the length(4) or 1(c(1)).

14)What are the components of R functions?

The different parts of a function are −

Function Name − It is the actual name of the function because it stored in R environment as an object with this name.
Arguments − An argument is a placeholder. When a function invokes, we pass a value to the
argument. Arguments are optional; that is, a function may contain no arguments. Also, arguments can have default values.
Functions Body – In a function body, statements can be collected. and hence, it defines what the function does.
Return Value − the return value of a function is the last expression in the function body to check.

15)How will you check if an element 25 is present in a vector?

There are various ways to do this-

It can be done using the match () function- match () function returns the first appearance of a particular element.
The other is to use %in% which returns a Boolean value either true or false.
Is.element () function also returns a Boolean value either true or false based on whether it is present in a vector or not.

16)What is the memory limit of R?

In 32 bit system memory limit is 3Gb but most versions limited to 2Gb and in 64 bit system memory limit is 8Tb.

17)Name the functions which helps in importing data from other applications in R?


18)What is the difference between rnorm and runif functions ?

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

Syntax of rnorm function –

rnorm(n, mean = , sd = )

runif function generates “n” unform random numbers in the interval of minimum and maximum values passed to the function.

Syntax of runif function –

runif(n, min = , max = )

19)How to create vectors in R?

a) To create a vector using integers:

For Example, We use the colon operator (:) in R.
The code 2:6 gives you a vector with the numbers 2 to 6, and 3:-4 create a vector with the numbers 3 to –4, both in steps of 1.

b) We use the seq() to make steps in a sequence.

Seq() function used to describe by which the numbers should decrease or increase.

For Example In R, the vector with a numbers 4.5 to 3.0 in steps of 0.5.

> seq(from = 4.5, to = 3.0, by = -0.5)
[1] 4.5 4.0 3.5 3.0 c
You can specify the length of the sequence by using the argument out. R calculates the step size itself. For Example We can make a vector of nine values going from –2.7 to 1.3 like this:

> seq(from = -2.7, to = 1.3, length.out = 9)
[1] -2.7 -2.2 -1.7 -1.2 -0.7 -0.2 0.3 0.8 1.3

20)What will be the result of multiplying two vectors in R having different lengths?

The multiplication of the two vectors will be performed and the output will be displayed with a warning message like – “Longer object length is not a multiple of shorter object length.” Suppose there is a vector a<-c (1, 2, 3) and vector b <- (2, 3) then the multiplication of the vectors a*b will give the resultant as 2 6 6 with the warning message. The multiplication is performed in a sequential manner but since the length is not same, the first element of the smaller vector b will be multiplied with the last element of the larger vector a.

For R Language Course Content Click Here