R Programming Interview Questions - Top Answers to R Interview Questions. Learn R programming language with simple and easy examples starting from R installation, language basics, syntax, literals, data types
R is a programming language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R. 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.
R Programming provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering,) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity. Polls, surveys of data miners, and studies of scholarly literature databases show that R's popularity has increased substantially in recent years.
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.
R Programming 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.

What is R Programming?
R is a programming language meant for statistical analysis and creating graphs for this purpose. Instead of data types, it has data objects which are used for calculations. It is used in the fields of data mining, Regression analysis, Probability estimation etc., using many packages available in it.

What are the different data objects in R?
There are 6 data objects in R. They are
  • vectors
  • lists
  • arrays
  • matrices
  • data frames
  • tables
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.
What makes a valid variable name in R?
A valid variable name consists of letters, numbers and the dot or underline characters. The variable name starts with a letter or the dot not followed by a number.
What is the main difference between an Array and a matrix?
A matrix is always two dimensional as it has only rows and columns. But an array can be of any number of dimensions and each dimension is a matrix. For example, a 3x3x2 array represents 2 matrices each of dimension 3x3.

How many types of data types are provided by R?
There are 5 types of data types present in R:
  1. Integer data type
  2. Numeric data type
  3. Character data type
  4. Complex data type
  5. Logical data type
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 4

What is the use of with () and by () function in R?
with () function applies an expression to a dataset.
#with (data,expression)
By () function applies a function t each level of a factors.
#by (data,factorlist,function)

How can you load and use csv file in R?
A csv file can be loaded using the read.csv function. R creates a data frame on reading the csv files using this function.

What is Visualization in R?
Visualization is any technique for creating images, diagrams, or animations to communicate a message. Visualization through visual imagery has been an effective way to communicate both abstract and concrete ideas since the dawn of humanity.

What are R topical programming and statistical relevance?
  • R is free, open source software.
  • R is available from free software Foundation.
  • Data inputs such as data type, importing data, keyboard typing.
  • Data Management such as data variables, operators.
How do you get the name of the current working directory in R?
The command getwd() gives the current working directory in the R environment.

What are statistical and programming features of R?
Statistical Features-
  • Basic Statistics: Mean, variance, median.
  • Static graphics: Basic plots, graphic maps.
  • Probability distributions: Beta, Binomial.
Programming Features-
  • Distributed Computing: Distributed computing is an open source, high-performance platform for the R language. It splits tasks between multiple processing nodes to reduce execution time and analyze large datasets.
  • R packages – R packages are a collection of R functions, compiled code and sample data. By default, R installs a set of packages during installation.
What is the use of subset() and sample() function in R?
Subset() is used to select the variables and observations and sample() function is used to generate a random sample of the size n from a dataset.

What are the advantages of R?
The advantages are:-
  • It is used for managing and manipulating of data.
  • No license restrictions
  • Free and open source software.
  • Graphical capabilities of R are good.
  • Runs on many Operating system and different hardware and also run on 32 & 64 bit processors etc.
What are the disadvantages of R Programming?
The disadvantages are:-
  • Lack of standard GUI
  • Not good for big data.
  • Does not provide spreadsheet view of data.
What is R Base package?
This is the package which is loaded by default when R environment is set. It provides the basic functionalities like input/output, arithmetic calculations etc. in the R environment.

What is the workspace in R?
Workspace is the current R working environment which includes any user defined objects like vector, lists etc.

How R is used in logistic regression?
Logistic regression deals with measuring the probability of a binary response variable. In R the function glm() is used to create the logistic regression.

What are different ways to call a function in R?
We can call a function in R in 3 ways. First method is to call by using position of the arguments. Second method id to call by using the name of the arguments and the third method is to call by default arguments.

How many sorting algorithms are available?
There are 5 types of sorting algorithms are used which are:-
  1. Bubble Sort
  2. Selection Sort
  3. Merge Sort
  4. Quick Sort
  5. Bucket Sort
What is lazy function evaluation in R?
The lazy evaluation of a function means, the argument is evaluated only if it is used inside the body of the function. If there is no reference to the argument in the body of the function, then it is simply ignored.

What is R lists?
Lists are the object which Contains elements of different types – like strings, numbers, vectors and another list inside it. A list can also contain a matrix or a function as its elements. The List is created using list() Function. In other words, a list is a generic vector containing other objects.
For Example, The variable x is containing copies of three vectors n, s, b and a numeric value 3.
n = c(2, 3, 5)
s = c(“aa”, “bb”, “cc”, “dd”, “ee” )
x = list( n, s, b, 3) # x contains copies of n, s, b)

How do you install a package in R?
To install a package in R we use the below command.
install.packages("package Name")

Which command is used for storing R object into a file?
Save command is used for storing R objects into a file.
Syntax: >save(z,file=”z.Rdata”)

Which command is used for restoring R object from a file?
load command is used for storing R objects from a file.
Syntax: >load(”z.Rdata”)

What is the use of abline() function?
abline() function is add the reference line to a graph.
Syntax:- abline(h=yvalues, v=xvalues)

What is reshaping of data in R?
In R the data objects can be converted from one form to another. For example we can create a data frame by merging many lists. This involves a series of R commands to bring the data into the new format. This is called data reshaping.

How to get a list of all the packages installed in R?
Use the command

What is Predictive Analysis in R?
Predictive analysis is the branch of advanced analysis. It used to make predictions about unknown future events. The Predictive analysis contains data collection, statistics, and deployment. It uses many techniques from data mining, statistics, machine learning and analyzes current data to make predictions about future. It also allows the business users to create Predictive intelligence.

What is Predictive analysis process in R?
Define Project – It includes Project outcomes, business objectives, deliverables, scoping of the effects.
Data Collection – For predictive analysis, it collects data from different sources to analysis. Thus it provides a complete view of customer interactions.
Data Analysis – It is the process of cleaning, transforming, inspecting and modeling data. The goal of this process is to discover useful information.
Statistics – This process enables to confirm the assumptions. Hence it uses the assumption to test using a statistical model.
Modeling – An accurate predictive model about future is been created using predictive modeling. There are also options to choose the best model.
Deployment – To deploy the analytical results into everyday decision-making.
Model Monitoring – To ensure that it is providing an expected result, we have to manage model.

What is Descriptive analysis in R?
It does exactly what the name Implies “Describe”. it allows us to learn from our past and to understand how they might influence future outcomes. The main goal of is to find out the reasons behind previous success or failure in the past. Hence, Most of the social analysis is descriptive analysis. For Example – the company’s production, financials, operations, sales, finance, inventory, and customers.

What are Descriptive analysis methods in R?
Observation Method – There are two ways to draw the meaningful conclusion: Artificial & Natural.
Survey Method – In this method, questionnaires prepares and given to the participants. Hence After receiving the answers, the research preceded and results concluded.
Case Method – It involves a deep study of all the problems discussed. Thus, it makes us understand a particular situation.

What are R Functions?
A function is a piece of code written to carry out a specified task. Thus it can or can’t accept arguments or parameters and it can or can’t return one or more values. In R, functions are objects in their own right. Hence, we can work with them exactly the same way we work with any other type of object.

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 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 R matrices and R matrices functions?
A matrix is a two-dimensional rectangular data set. Thus it can create using vector input to the matrix function. Also, a matrix is a collection of numbers arranged into a fixed number of rows and columns. Usually, the numbers are the real numbers. We reproduce a memory representation of the matrix in R with the matrix function. Hence, the data elements must be of the same basic type. Matrices functions are those functions which we use in matrices. There are two types of matrices functions:
  • apply()
  • sapply()
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.

Name all control statements present in R?
  • If
  • If-else
  • For
  • Nested loops
  • While
  • Repeat and break
  • Next
  • Return
What is Recursive Function in R?
Recursive functions call themselves. They break down the problem into the smallest possible components. The function () calls itself within the original function () on each of the smaller components. After this, the results will put together to solve the original problem.

What are applications of Recursion?
Dynamic Programming
It is the process of avoiding recomputation. It is an essential tool for statistical programming. There are two types of dynamic programming:
Bottom-up dynamic programming
  • In this, we check function starting with smallest possible argument value.
  • All computed values will be stored in an array.
Top-down dynamic programming
  • Save each computed value as the final act of a recursive function.
  • Check if pre-computed values exist as the first action.
Divide-And-Conquer Algorithms
  • It is a Common class of recursive function.
  • Common features of this algorithm are process inputs, divide the input into
  • Smaller portions, Recursive call(s) process at least one part.
  • Recursion may sometimes occur before the input is been processed.
What is TCP/IP in R?
TCP/IP is a set of protocols. It is a primary tech of the internet. When we browse the web, send email, chat online, online gaming, TCP/IP is working underneath.

What does TCP/IP work?
TCP/IP protocols map to a four-layer conceptual model known as the DARPA model. The four layers of the DARPA model are Application, Transport, Internet, and Network Interface.

Explain TCP/IP applications, services and protocols?
Bootstrap protocol – Bootstrap Protocol (BOOTP) provides a dynamic method for associating workstations with servers. It is a method which also provides a dynamic method for assigning workstation Internet Protocol (IP) addresses and initial program load (IPL) sources.
Domain name system – We use Domain Name System (DNS) to manage host names and their associated Internet Protocol (IP).
Email – Use this information to plan for, configure, use, manage, and troubleshoot e-mail on your system.
Open shortest path first search – IBM I support includes the Open Shortest Path First (OSPF) protocol. OSPF is a link-state, hierarchical Interior Gateway Protocol (IGP) for network routing.
RouteD – The Route Daemon (RouteD) provides support for the Routing Information Protocol (RIP) on the IBM platform.
Simple network time protocol – It is a time-maintenance application that we can use to synchronize hardware in a network.

How many types of functions are there in R string manipulation?
There are 8 functions in R string manipulation respectively
  • grep()
  • nchar()
  • paste()
  • sprintf()
  • substr()
  • strsplit()
  • regex()
  • gregexpr()
Request to Download PDF

Post A Comment: