September 24, 2018

Sreekanth B

VeriSign R Programming Recently Asked Interview Questions Answers

What is R matrices?

A matrix is a two-dimensional rectangular data set and thus it can be created using vector input to the matrix function. In addition, a matrix is a collection of numbers arranged into a fixed number of rows and columns. Usually, the numbers are the real numbers. By using a matrix function we can reproduce a memory representation of the matrix in R. Hence, the data elements must be of the same basic type.

How many methods are available to use the matrices?

There are so many methods to solve the matrices like adding, subtraction, negative etc.

What is control structure in R?

R has the standard control structures we would expect. expr can be multiple statements by enclosing them in braces { }. It is more efficient to use built-in functions rather than control structures whenever possible. These allow us to control the flow of execution of a script typically inside of a function. Control structures define the flow of the program. The decision is been based on the evaluation of a variable.

How many control statements are present in R?

There are eight control statements are present in R.
VeriSign R Programming Recently Asked Interview Questions Answers
VeriSign R Programming Recently Asked Interview Questions Answers

Name all control statements present in R?

Nested loops
Repeat and break

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.

What is GUI in R?

GUI stands for Graphical User Interfaces. R is a command line driven program. The user enters commands at the prompt ( > by default ) and each command is executed one at a time. There have been a number of attempts to create a more graphical interface, ranging from code editors that interact with R, to full-blown GUIs that present the user with menus and dialog boxes.

What is CLI in R?

CLI stands for Command Line Interface. In a command line interface, you type commands that you want to execute and press return. For example, if you type the line 2+2 and press the return key, R will give you the result [1] 4

What is data mining and what data miners do in R?

R and Data Mining introduces researchers, post-graduate students, and analysts to data mining using R, a free software environment for statistical computing and graphics.

Who and When R discovered?

R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, and is currently developed by the R Development Core Team, of which Chambers is a member. R is named partly after the first names of the first two R authors and partly as a play on the name of S.The project was conceived in 1992, with an initial version released in 1995 and a stable beta version in 2000.

Explain how to access list elements in R?

Create a list containing a vector, a list and a matrix.

list_data <- list(c("Feb","Mar","Apr"))
list("white",13.4)), matrix(c(3,9,5,1,-2,8), nrow = 2)
For Example: Give names to the elements in the list:

Names(list_data) <- c(“1 st  Quarter”, “A Matrix”, “A Inner list”)

Access the first element of the list:


Access the third element. As it also a list, all its elements will print:


By using the name of the element access the list elements:

Print(list_data$A Matrix)

It will produced the following result after executing the above code:

$”1 st  Quarter” [1] “Feb”, "Mar”, "Apr”
[1] “White”
[1] 13.4
$ “A Matrix” [1]
[1]   [2]   [3]
[1]     3     5    -2
[2]     9     1     8

Explain how to manipulate list elements in R?

Create a list containing a vector, a matrix and a list.

list_data <- list(c("Feb","Mar","Apr"),
matrix(c(3,9,5,1,-2,8), nrow = 2), list("green",12.3))
For Example:

Give names to the elements in the list:

names(list_data) <- c("1st Quarter", "A_Matrix", "A Inner list")

Add element at the end of the list:

list_data[4] <- "New element"
Remove the last element:

list_data[4] <- NULL # Print the 4th Element.print(list_data[4])

Update the 3rd Element:

list_data[3] <- "updated element"
When we execute the above code, it produces the following result:

[1] "New element"
$`A Inner list`
[1] "updated element"

Explain how to generate lists in R?

We can use a colon to generate a list of numbers. For example:

[1] -3 -2 -1 0 1 2 3

Explain how to operate on lists in R?

R allows to Operate on all list values at once. For example:

c(1,3,5) + 4

This and the Apply function allow you to avoid most for loops.

[1] 5, 7, 9

What are features of R functions?

Function component describes the three main components of a function.

Lexical scoping teaches how R finds values from names.
In R, every operation is a function call.
Function arguments discuss the three ways of supplying arguments to a function. it shows to call
The function is given a list of arguments and to the impact of lazy evaluation.
Special calls describe two special types of function infix and replacement functions.
Return values discuss how and when functions return values. it also shows how you can ensure
that a function does something before it exists.

What is function definition?

An R function is been created using the keyword function. The basic syntax of an R function definition is as follows −
function_name <- function(arg_1, arg_2, …) {
Function body

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.

What are Generic Functions in R?

R has three object-oriented (OO) systems: [[S3]], [[S4]] and [[R5]]. … A method is a function associated with a particular type of object. S3 implements a style of object-oriented programming called generic-function OO.

What are R packages?

Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages. Others are available for download and installation. Once installed, they have to be loaded into the session to be used.

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


What is more functions in R and name them?

We have to load the built-in foreign command to use these functions:


R more functions:


List out some of the function that R provides?


What is the distribution in R?

R Functions for Probability Distributions. Every distribution that R handles has four functions. There is a root name, for example, the root name for the normal distribution is the norm. This root is prefixed by one of the letters. p for “probability”, the cumulative distribution function (c. d. f.)

What are vector functions?

In R, a function is a piece of code written to carry out a specified task. R Functions are called as objects because we can work with them exactly the same way we work with any other type of object. Vector functions are those functions which we used in vectors.
For Example: rep(), seq(), using all() and any(), more on c() etc.

Most common functions which we use in vector operations are –


Explain how to repeat vectors in R?

We can use the rep() function in several ways if we want to repeat the complete vector. For examples: specify the argument times 1. To repeat the vector c(0, 0, 7) three times, use this code:

> rep(c(0, 0, 7), times = 4)
[1] 0 0 7 0 0 7 0 0 7 0 0 7 2
We can also repeat every value by specifying the argument each, like this:

> rep(c(2, 4, 2), each = 2)
[1] 2 2 4 4 2 2 3
We can tell R for each value how often it has to repeat:

> rep(c(0, 7), times = c(4,3))
[1] 0 0 0 0 7 7 7 4
In seq, we use the argument length.out to define R. it will repeat the vector until it reaches that length, even if the last repetition is incomplete.

> rep(1:3,length.out=9)
[1] 1 2 3 1 2 3 1 2 3

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

Can we update and delete any of the elements in a list?

We can update any of the element but we can delete only the element at the end of the list.

How many types of object are present In R?

There are 6 types of objects present in R:

Data Frames
Subscribe to get more Posts :