125 R Interview Questions and Answers For Freshers & Experienced

Expert-led Online Courses: Elevate Your Skills, Get ready for Future - Enroll Now!

1. R Interview Questions and Answers

In our previous R blog, we have discussed all the topics related to R Programming in detail. In this blog, we are going to provide you a top R Interview Questions and Answers. Here we will discuss the top 125 R Interview Questions and Answers for both Freshers and Experienced. Links are also provided along with the questions to the deep understanding of the topic. Hope this blog will help you a lot to crack R Interview. Happy Job Hunting:-)

125 R Interview Questions and Answers For Freshers & Experienced

125 R Interview Questions and Answers For Freshers & Experienced

2. Frequently Asked R Interview Questions and Answers

Q.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.
Read more about R Programming in detail.

R Interview Questions and Answers

R Interview Questions and Answers – Q.1

Q.2. 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.
Read more about R Programming in detail.
Q.3. 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
Q.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.
Q.5. 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.

R interview Questions and Answers - R Discovery

R interview Questions and Answers – R Discovery

Q.6. 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.
Why R - R interview Questions and Answers

Why R – R interview Questions and Answers

Read more reasons to learn R Programming.
Q.7. What are programming features of R?

  • Packages are part of R programming. Hence, they are useful in collecting sets of R functions into
    a single unit.
  • R’s programming features include database input, exporting data, viewing data, variable labels,
    missing data, etc.
  • R is an interpreted language. So we can access it through command line interpreter.
  • R supports matrix arithmetic.
  • R supports procedural programming with functions and object-oriented programming with
    generic functions. Procedural programming includes procedure, records, modules, and
    procedure calls while object-oriented programming language includes class, objects, and
    functions.
R Interview Questions - R Programming Features

R Interview Questions – R Programming Features

Q.8. What are the applications of R?

  • Many data analysts and research programmers use R because R is the most prevalent language. Hence, R is used as a fundamental tool for finance.
  • Many quantitative analysts use R as their programming tool. Hence, R helps in data importing and cleaning, depending on what manner of strategy you are using on.
  • R is best for data Science because it gives a broad variety of statistics. In addition, R provides the environment for statistical computing and design. Rather R considers as an alternate execution of S.

    R interview Questions and Answers - R Applications

    R interview Questions and Answers – R Applications

Learn More R Applications in detail.
Q.9. Compare R with other technologies.

  • Data handling Capabilities – Good data handling capabilities and options for parallel computation.
  • Availability / Cost – R is an open source and we can use it anywhere.
  • Advancement in Tool –  if you are working on latest technologies, R gets latest features.
  • Ease of Learning – R has a learning curve. R is a low-level programming language. As a result, simple procedures can take long codes.
  • Job Scenario – It is a better option for start-ups and companies looking for cost efficiency.
  • Graphical capabilities – R is having the most advanced graphical capabilities. Hence, it provides us advanced graphical capabilities.
  • Customer Service support and community – R is the biggest online growing community.

Q.10. Why is R Important?
R is a leading tool for machine learning, statistics, and data analysis. It is a programming language. By using R we can create objects, functions, and packages. R language is a platform independent so we can use it on any operating systems. The installation of R is free so we can use it without purchasing a license. R is not only statistic package and is an open source. It means anyone can examine the source code to see what exactly is doing on screen. Anyone can add a feature and fix bugs without waiting for the vendor to do this. Thus, it allows you to integrate with other languages (C, C++). It also enables you to interact with many data sources and statistical packages (SAS, SPSS). R has large growing community of users.

Basic R Interview Questions and Answers

Q.11. Is R is a slow language?

  • R programs can be slow, but well-written R programs are usually fast enough.
  • Speed was not the primary design criteria.
  • Designed to make programming easier.
  • Slow programs often a result of bad programming practices or not
    understanding how R works.
  • There are various options for calling C or C++ functions from R.

Q.12. Explain main features to write R code that runs faster?
R is a popular statistical software which is famous for the enormous amount of packages. R’s syntax is very flexible with making it convenient at the cost of performance. R is indeed slow compared to many other scripting languages, but there are a few tricks which can make our R code run faster.

  • Use matrix instead of data frame whenever possible. Actually data frame cause problem in many cases. Only use data frame when necessary.
  • Use double(n) to create a vector of length n instead of using code rep(0,n), and similar to others.
  • Split big data object (e.g., big data frame or matrix) to smaller ones, and operate on these smaller objects.
  • Use for each(i=1:n) %dopar% {} to do parallel computing if applicable. Even if a for loop is not parallelizable, for each(i=1:n) %do% {} is a better alternative.
  • Use vector and matrix operation if possible. Theses *apply functions are very helpful for this purpose.
  • Avoid changing the type and size of an object in R. Though we use R object as if they are typeless, they have type actually. In R, changing the type and size of an R object forces it to reallocate a memory space which is of course insufficient.
  • Avoid creating too many objects in each working environment. Not having enough memory can not only make your code run slower but also make it fail to run if have to allocate big vectors. One way to do this is to write small functions and run your functions instead of running everything directly in a working environment.

Q.13. 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.
Q.14. Why is R important for data science?

  • We can run your code without any Compiler – R is an interpreted language. Hence we can run Code without any compiler. R interprets the Code and makes the development of code easier.
  • Many calculations done with vectors – R is a vector language, so anyone can add functions to a single Vector without putting in a loop. Hence, R is powerful and faster than other languages.
  • Statistical Language- R used in biology, genetics as well as in statistics. R is a turning complete
    a language where any type of task can be performed.

Q.15. Why is R Good for business?

  • The most important reason why R is good for business is that it is an open source. R is great for visualization. As per new research, R has far more capabilities as compared to earlier tools.
  • For data-driven business, data science talent shortage is a very big problem. Companies are
    using R programming as their platform and recruit trained users of R.

Q.16. 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.
Q.17. What are R topical programming and statistical relevance?
a) Statistical

  • R is free, open source software.
  • R is available from free software Foundation.

b) Programming

  • Data inputs such as data type, importing data, keyboard typing.
  • Data Management such as data variables, operators.

Q.18. What are statistical and programming features of R?

R Interview Questions and answers

R Interview Questions and answers

a) Statistical Features-

  • Basic Statistics: Mean, variance, median.
  • Static graphics: Basic plots, graphic maps.
  • Probability distributions: Beta, Binomial.

b) 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.

Q.19. What are the advantages of R?

  • R is the most comprehensive statistical analysis package as new technology and ideas often appear first in R.
  • R is open-source software. Hence anyone can use and change it.
  • R is an open source. We can run R anywhere and at any time, and even sell it under conditions of the license.
  • R is good for GNU/Linux and Microsoft Windows. R is cross-platform which runs on many operating systems.
  • In R, anyone is welcome to provide bug fixes, code enhancements, and new packages.
Advantages of R - R programming interview questions

Advantages of R – R programming interview questions

Q.20. What are the disadvantages of R?

  • In R, quality of some packages is less than perfect.
  • In R, no one to complain, if something doesn’t work.
  • R is a software Application that many people devote their own time to developing.
  • R commands give little thought to memory management, and so R can consume all available memory.
Disadvantages of r - r programming questions and answers

Disadvantages of r – r programming questions and answers

R interview Questions For Freshers

Q.21. Why R language?

  • In R, quality of some packages is less than perfect.
  • In R, no one to complain, if something doesn’t work.
  • R is a software Application that many people devote their own time to developing.
  • R commands give little thought to memory management, and So R can consume all available memory.

Q.22. 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.
Learn about R predictive Analysis in detail.
Q.23. 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.
Predictive analysis process in R - r language interview questions

Predictive analysis process in R – r language interview questions

Q.24. What is the need for Predictive Analysis in R?

  • Secure a competitive Stronghold It helps you to play your competitors’ weaknesses and company’s strengths. Hence, it allows you to check the actions of consumers and your competitors’ marketing and sales.
  • Do more than evaluating the past Employee analysis helps to check your company details. It will summarize past failure or past success. Therefore, the most important thing is that predictive analysis helps in learning from past experiences.
  • Maintain business integrity by managing fraud, First of all, Fraud investigators can look into only a set number of cases each week. Secondly, they use company’s past experience to score transactions according to their level of risk.
  • Advance your core business Capability The next step to growth is to improve company core offering. Thus At its core, it focuses on using it to optimize your approach to the market.

Q.25. 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.
Learn more about R Descriptive Analysis in detail.
Q.26. 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.
Descriptive analysis methods in R

Descriptive analysis methods in R

Q.27. What is R studio and how to use it?
a) USING RSTUDIO

  • step 1: Download and install Rstudio.
  • step 2: Open RStudio and do this:
  • step 3: Click on the menu: File -> New -> R Script
  • step 4: Paste the code in the new source code area
  • step 5: Click the “Source” button above the code area:

We can also use the console in RStudio. If we click “Run” instead of “Source” user input might not work properly. We can use the R documentation like this: help(function.name).

  • Using the R console – Running the r program on the command line or elsewhere will start the console. we can paste your code there.
  • Problems with this approach – If we use source(“filename.r”) to run your code then it will surely work. But If we paste the code some of it might be read as user input.
  • Running a source file with R – We can run a source file like this: r -f filename.r.
    R also provides a lot of other command line arguments

Learn about R Studio in detail.
Q.28. What are R data types?
In programming, a data type is a classification that specifies what type of a value variable has. It also describes what type of relational, mathematical and logical operations can apply to it without causing an error. We need to use various variables to store information while doing programming in any programming language. Variables are nothing but reserved memory locations to store values. This means that when we create a variable we reserve 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.
Read about R Data Types in detail.
Q.29. 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
Data Types - R questions and answers

Data Types – R questions and answers

Q.30. 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 3×3.
Q.31. What is R vector?
The basic data structure in R is the vector. It comes in two parts: atomic vectors and lists. They have three common properties:

  • Type function, what it is?
  • Length function, how many elements it contains.
  • Attribute function, extra arbitrary metadata. They differ in the types of their elements: All elements of an atomic vector must be the same type, whereas the elements of a list can have different types.

Learn R Vectors in detail.
Q.32. How many types of vectors are present in R?

  • Atomic Vector
  • Combining Vector
  • Vector arithmetic
  • Logical index vector
  • Numeric index
  • Duplicate Index
  • Range Indexes
  • Out-of-order Indexes
  • named Vectors Members

Q.33. What is an Atomic vector and how many types of atomic vectors are present in R?
The atomic vector is the simplest R data type. Atomic vectors are linear vectors of a single primitive type, like an STL Vector in C++. There are four types of atomic vectors are present in R:

  • Numerical datatype
  • Integer datatype
  • Character datatype
  • Logical datatype

Q.34. What is recycling of elements in an R 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.
Q.35. 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” )
b = c(TRUE,  FALSE,  TRUE,  FALSE,  FALSE )
x = list( n, s, b, 3)        # x contains copies of n, s, b)
Learn more about R Lists in detail.
Q.36. Explain how to create a list in R?
Create a list containing string, numbers, vectors and logical values. For Example:
[php]List_data <- list(“Green”, “Yellow”, c(5,6,7), TRUE, 51.2)[/php]
print(list_data) When we execute the above code, it produces the following result-
[php][[1]]
[1] “Green”
[[2]]
[1] “Yellow”
[[3]]
[1] 5, 6, 7
[[4]]
[1] TRUE
[[5]]
[1] 51.2[/php]
Q.37. Explain how to access list elements in R?
Create a list containing a vector, a list and a matrix.
[php]list_data <- list(c(“Feb”,”Mar”,”Apr”))
list(“white”,13.4)), matrix(c(3,9,5,1,-2,8), nrow = 2)[/php]
For Example: Give names to the elements in the list:
[php]Names(list_data) <- c(“1 st  Quarter”, “A Matrix”, “A Inner list”)[/php]
Access the first element of the list:
[php]print(list_data[1])[/php]
Access the third element. As it also a list, all its elements will print:
[php]Print(list_data[3])[/php]
By using the name of the element access the list elements:
[php]Print(list_data$A Matrix)[/php]
It will produced the following result after executing the above code:
[php]$”1 st  Quarter” [1] “Feb”, “Mar”, “Apr”
$A_Inner_list
$A_Inner_list[[1]]
[1] “White”
$A_Inner_list[[2]]
[1] 13.4
$ “A Matrix” [1]
[1]   [2]   [3]
[1]     3     5    -2
[2]     9     1     8[/php]
Q.38. Explain how to manipulate list elements in R?
Create a list containing a vector, a matrix and a list.
[php]list_data <- list(c(“Feb”,”Mar”,”Apr”),
matrix(c(3,9,5,1,-2,8), nrow = 2), list(“green”,12.3))[/php]
For Example:
Give names to the elements in the list:
[php]names(list_data) <- c(“1st Quarter”, “A_Matrix”, “A Inner list”)[/php]
Add element at the end of the list:
[php]list_data[4] <- “New element”
print(list_data[4])[/php]
Remove the last element:
[php]list_data[4] <- NULL # Print the 4th Element.print(list_data[4])[/php]
Update the 3rd Element:
[php]list_data[3] <- “updated element”
print(list_data[3])[/php]
When we execute the above code, it produces the following result:
[php][[1]]
[1] “New element”
$NULL
$`A Inner list`
[1] “updated element”[/php]
Q.39. Explain how to generate lists in R?
We can use a colon to generate a list of numbers. For example:
[php]-3:3
[1] -3 -2 -1 0 1 2 3[/php]
Q.40. Explain how to operate on lists in R?
R allows to Operate on all list values at once. For example:
[php]c(1,3,5) + 4[/php]
This and the Apply function allow you to avoid most for loops.
[php][1] 5, 7, 9[/php]
Q.41. 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.
Q.42. How many types of object are present In R?
There are 6 types of objects present in R:

  • Vectors
  • Matrices
  • Arrays
  • Lists
  • Data Frames
  • Factors
r interview questions - Types of objects

r interview questions – Types of objects

Q.43. 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.
learn more about R Functions in detail.
Q.44. 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.

Q.45. 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
}
Q.46. 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.
r programming interview questions - Components of R Functions

r programming interview questions – Components of R Functions

Q.47. 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.
Q.48. 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.
Learn more about R Packages in detail.
Q.49. Name the functions which helps in importing data from other applications in R?

  • read.table()
  • readlines()
  • read.fwf
  • read.delim()
  • scan()
  • read.csv()
  • read.csv2()
Functions helps in importing the data - R interview questions

Functions helps in importing the data – R interview questions

R Interview Questions for Experienced

Q.50. What is more functions in R and name them?
We have to load the built-in foreign command to use these functions:
[php]>library(“foreign”)[/php]
R more functions:

  • read.xpss
  • read.xport
  • read.dta

Q.51. List out some of the function that R provides?

  • Mean
  • Median
  • Distribution
  • Covariance
  • Regression

Q.52. 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.)
Q.53. 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 –

  • rep()
  • seq()

Learn more about R vector Functions in detail.
Q.54. 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:
[php]> rep(c(0, 0, 7), times = 4)
[1] 0 0 7 0 0 7 0 0 7 0 0 7 2[/php]
We can also repeat every value by specifying the argument each, like this:
[php]> rep(c(2, 4, 2), each = 2)
[1] 2 2 4 4 2 2 3[/php]
We can tell R for each value how often it has to repeat:
[php]> rep(c(0, 7), times = c(4,3))
[1] 0 0 0 0 7 7 7 4[/php]
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.
[php]> rep(1:3,length.out=9)
[1] 1 2 3 1 2 3 1 2 3[/php]
Q.55. 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.
[php]> seq(from = 4.5, to = 3.0, by = -0.5)
[1] 4.5 4.0 3.5 3.0 c[/php]
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:
[php]> 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[/php]
Q.56. What is using all() and any()?
a) na.rm – State whether NA values should ignore.
b) any(…, na.rm=FALSE) … – One or more R objects that need to be check. na.rm – State whether NA values should ignore. The any() and all() functions are shortcuts because they report any or all their arguments are TRUE.
[php]> x <- 1:10 > any(x > 5)
[1] TRUE
> any(x > 88)
[1] FALSE
> all(x > 88)
[1] FALSE
> all(x > 0)
[1] TRUE For Example: Suppose that R executes the following:
> any(x > 5)[/php]
It first evaluates x > 5:
[php](FALSE, FALSE, FALSE, FALSE, FALSE)[/php]
We use any() function – that reports whether any of those values are TRUE while all() function works and
reports if all the values are TRUE.
Q.57. What is R’s C interface?
R’s source code is a powerful technique for Improving Programming skills. But, many base R function was already written in C. It is been used to figure out how those functions work. All functions in R defined with the prefix Rf_ or R_.
Outline of Rs C interface

  • Input Validations talks about itself so that C function doesn’t crash R.
  • C data Structures shows how to translate data structure names from R to C.
  • Creating and modifying vectors teaches how to create, change, and make vectors in C.
  • Calling C defines the basics of creating. It also defines the functions with the inline package.

Q.58. What are Prerequisites for R’s C interface?
We need a C compiler for C interface. Windows users can use Rtools. Mac users will need the Xcode command line tools. Most Linux distributions will come with the necessary compilers. In Windows, it is necessary to include Windows PATH environment variable in it:

  • Rtools executables directory (C:\Rtools\bin),
  • C compiler executables directory (C:\Rtools\gcc-4.6.3\bin).

Q.59. How to call C function from R?
Generally, to call a C function it required two pieces:

  • C function.
  • R wrapper function that uses.Call().

The function below adds two numbers together:
[php]// In C — — — — — — — — — — — — — — — — — — — —
#include <R.h>
#include <Rinternals.h>
SEXP add(SEXP a, SEXP b) {
SEXP result = PROTECT(allocVector(REALSXP, 1));
REAL(result)[0] = asReal(a) + asReal(b);
UNPROTECT(1);
return result;
}
# In R — — — — — — — — — — — — — — — — — — — —
add <- function(a, b) {
.Call(“add”, a, b}
}[/php]
Q.60. 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()

Learn more about R matrices and Matrices Functions in detail.
Q.61. What is apply() function in R?
Return a vector or array or list of values obtained by applying a function to margins of an array or matrix.
Keywords
array, iteration
Usage
[php]apply(X, MARGIN, FUN, …)[/php]
Arguments

  • X – an array, including a matrix
  • … – optional arguments to FUN
  • FUN – The function to apply: see ‘Details’
  • MARGIN -Functions will apply on subscripts in a vector.

Q.62. What is the apply() family in R?
Apply functions are a family of functions in base R. which allow us to perform an action on many chunks of data. An apply function is a loop, but run faster than loops and often must less code. There are many different apply functions. The called function could be:

  • There is some aggregating function. They include meaning, or the sum(includes return a number or scalar);
  • Other transforming or subsetting functions.
  • There are some vectorized functions. They return more complex structures like lists, vectors, matrices, and arrays.
  • We can perform operations with very few lines of code in apply().

Q.63. What is sapply() in R?
A Dimension Preserving Variant of “sapply” and “lapply”
sapply is a user-friendly version. It is a wrapper of lapply. By default sapply returning a vector, matrix or an array.
Keywords
Misc, utilities
Usage
[php]Sapply(X, FUN, …, simplify = TRUE, USE.NAMES = TRUE)
Lapply(X, FUN, …)[/php]
Arguments

  • X – It is a vector or list to call sapply.
  • FUN – a function.
  • … – optional arguments to FUN.
  • simplify – It is a logical value which defines whether a result is been simplified to a vector or
  • matrix if possible?
  • USE.NAMES – logical; if TRUE and if X is a character, use X as names for the result unless it had names already.

Q.64. How to use sapply in R?
Multipy all values by 10:
[php]> sapply(BOD,function(x) 10 * x)
Time demand
[1,] 10 80
[2,] 20 100
[3,] 30 190[/php]
Used for array, margin set to 1:
[php]> x <- array(1:9) > sapply(x,function(x) x * 10)
[1] 10 20 30 40 50 60 70 80 90[/php]
Two dimension array, margin can be 1 or 2:
[php]> x <- array(1:9,c(3,3)) > x
[,1]   [,2]   [,3]
[1,]      1      4      7
[2,]      2      5      8
[3,]      3      6      9
> sapply(x,function(x) x * 10)
[1] 10 20 30 40 50 60 70 80 90[/php]
sapply: returns a vector, matrix or an array
# sapply : returns a vector, an array or matrix
[php]sapply(c(1:3), function(x) x^2)
[1] 1 4 9[/php]
Q.65. 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.
learn R matrices in detail.
Q.66. How many methods are available to use the matrices?
There are so many methods to solve the matrices like adding, subtraction, negative etc.
Learn R Matrices Functions in detail.
Q.67. 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.
Learn R Control Structures in detail.
Q.68. How many control statements are present in R?
There are eight control statements are present in R.
Q.69. Name all control statements present in R?

  • If
  • If-else
  • For
  • Nested loops
  • While
  • Repeat and break
  • Next
  • return
R Control Statements - r programming interview questions

R Control Statements – r programming interview questions

Q.70. What is Recursion in R?
[php]calculate_sum() <- function(n) {
if(n <= 1) { return(n) } else { return(n + calculate_sum(n-1)) } } Output: > calculate_sum(4)
[1] 10[/php]
Here, calculate_sum(n-1) is been used to compute the addition up to that number.Let suppose the user passes 4 to

Advanced R Interview Questions

Q.71. 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.
For Example:
[php] Factorial <- function(N)
{
if (N == 0)
return(1)
else
return( N * Factorial (N-1))
}[/php]
Learn more about R Recursive Functions in detail.
Q.72. What are applications of Recursion?
a) Dynamic Programming 
It is the process of avoiding recomputation. It is an essential tool for statistical programming. There are two types of dynamic programming:
i) Bottom-up dynamic programming 

  • In this, we check function starting with smallest possible argument value.
  • All computed values will be stored in an array.

ii) 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.

b) 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.

Q.73. What are Features of Recursion?

  • The use of recursion, often, makes code shorter and looks clean.
  • It is a Simple solution for a few cases.
  • It expresses in a function that calls itself.
R interview questions - Features of Recursion

R interview questions – Features of Recursion

Q.74. What is OOP in R?
Object-oriented programming is a popular programming language. It allows us to construct modular pieces of code which are used as building blocks for large systems. R is a functional language. It also supports exists for programming in an object-oriented style. OOP is a superb tool to manage complexity in larger programs. It is particularly suited to GUI development. R has two different OOP systems, known as S3 and S4.
Learn more about R Object Oriented programming in detail.
Q.75. What is S3 in R?
The S3 class is used to overload any function. It means calling a different name of the function. It depends upon the type of input parameter or the number of a parameter).
Q.76. What is S4?
The S4 class is a characteristic OOP system, but it is tricky to debug.
Q.77. What is reference class?
Reference classes are the modern alternative for S4 classes.
Q.78. How to create the S3 class?
We can show how to define a function that will create and return an object of a given class. A list is been created with the relevant members, the list’s class is set, and a copy of the list is been returned.
Q.79. How to construct a new S3 class?
For Example:
[php]> jim <- list(height = 2.54 * 12 * 6/100, weight = 180/2.2,+ name = “James”) > class(jim) <- “person” > class(jim)[/php]
We have now made an object of class person
We now define a print method.
[php]> print(jim)
> print.person <- function(x, …) { + cat(“name:”, x$name, “\n”) + cat(“height:”, x$height, “meters”, “\n”) + cat(“weight:”, x$weight, “kilograms”, “\n”) + } > print(jim)[/php]
Note the method/class has the ”dot” naming convention of method.class.
Q.80. What is inheritance in S3 class?
In S3, inheritance is achieved by the class attribute being a vector.
For Example:
[php]> fit <- glm(rpois(100, lambda = 1) ~ + 1, family = “poisson” > class(fit)
> methods(“residuals”)
> methods(“model.matrix”)[/php]
If no method for the first is found, the second class is checked.
Q.81. What are useful S3 method functions?

  • methods(“print”) and methods(class = “lm”)
  • getS3method(“print”,”person”) : Gets the appropriate method associated with a class, useful to see how a method is implemented.
  • Sometimes, methods are non-visible, because they are hidden in a namespace. Use getS3method or getAnywhere to get around this-

[php]> residuals.HoltWinters
> getS3method(“residuals.HoltWinters”)
> getAnywhere(“residuals.HoltWinters”)[/php]
Q.82. How to construct new S4 class?
[php]velocity = c(0.0,0.0)
),
# Make a function that can test to see if the data is consistent.
# This is not called if you have an initialize function defined!
validity=function(object)
{
if(sum(object@velocity^2)>100.0) {
return(“The velocity level is out of bounds.”)
}
return(TRUE)
}
)[/php]
Now that the code to define the class is given we can create an object whose class is Agent.
[php]> a <- Agent() > a
An object of class “Agent”
Slot “location”:
[1] 0 0
Slot “velocity”:
[1] 0 0
Slot “active”:
[1] TRUE[/php]
Q.83. What is S4 Generic?
The function setGeneric is the call to make a new generic function.
[php]> setGeneric(“BMI”, function(object) standardGeneric(“BMI”))
> setMethod(“BMI”, “personS4”, function(object) {
+ object@weight/object@height^2
+ })
> BMI(jimS4)[/php]
Q.84. How to request an input from the user through keyboard and monitor?
In R, there are a series of functions that can be used to request an input from the user,
including readline(), cat(), and scan(). But, I find the readline() function to be the optimal function for this task.
Learn more about Input Output functions in R.
Q.85. How to read data from the keyboard?
To read the data from keyboard we use three different functions:

  • scan()
  • readline()
  • print()

Q.86. How many ways are there to read and write files?
There are three ways to read and write files respectively:

  • Reading a data or matrix from a file
  • Reading a single File One Line at a Time
  • Writing a Table to a File
r interview questions - read and write files in R

r interview questions – read and write files in R

Q.87. Explain how to read data or a matrix from a file?
a) Usually we use function read.table() to read data. The default value of a header is ‘FALSE’ and hence when we do not have a header, we need not say such. , R factors are also called as character strings. For turning this “feature” off, you can include the argument as.is=T in your call to read.table().
b) When you have a spreadsheet export file, i.e. having a type.csv where the fields are divided by commas in place of spaces, use read.csv() in place of read.table(). To read spreadsheet files we can use read.xls.
c) When you read in a matrix using read.table(), the resultant object will become a data frame, even when all the entries got to be numeric. A case exists which may followup call towards as.matrix() in a matrix. We need to read it into a matrix form like this
> x <- matrix(scan(“x”),nrow=5,byrow=T)
Q.88. What are connections In R?
Functions to Manipulate Connections (Files, URLs, …). Functions to create, open and close connections.
For example: “generalized files”, such as compressed files, URLs, pipes, etc.
Keywords
file, connection
Learn more about the connections in R.
Q.89. Explain an Extended example of connections?
Extended Example: Reading PUMS sample files
These files contain records for a sample of housing units with information on the characteristics of each unit.

  •  Why use PUMS?

PUMS files provide greater accessibility to inexpensive data for research projects. Thus it is beneficial for students as they are looking for greater accessibility to inexpensive data. Social scientists often use the PUMS for regression analysis and modeling applications.

  • How can I access PUMS?

Statistical software is the tool used to work with PUMS files.
Q.90. Which function is used to write files?
We use write.csv() to write files.
Q.91. Explain how to write files?
We use write.csv() to write file. By default, write.csv() includes row names.
[php]# A sample data frame
data <- read.table(header=TRUE, text=’
subject sex size
1 M 7
2 F NA
3 F 9
4 M 11
‘)
# Write to a file, suppress row names
write.csv(data, “data.csv”, row.names=FALSE)
# Same, except that instead of “NA”, output blank cells
write.csv(data, “data.csv”, row.names=FALSE, na=” “)
# Use tabs, suppress row names and column names
write.table(data, “data.csv”, sep=”\t”, row.names=FALSE, col.names=FALSE)[/php]
Q.92. 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.
Learn more about TCP/IP in R.
Q.93. What is TCP/IP variable SMC-R storage allocations?

  • Each more RMB that is been allocated for a particular SMC-R link group can accommodate 4 – 32
    more TCP connections, depending on the RCVBFRSIZE value of the TCP connections.
  • More staging buffers are allocated as the volume of application data that is been sent increases.
  • RMBs, staging buffers, and RDMA receive and send elements are all eligible to be deallocated if the volume of application traffic decreases.

Q.94. What are Sockets in R?
Sockets provide two networked machines with a bidirectional communication channel. Servers are accessed via socket addresses, a combination of the server’s IP address and a port number. We use the port as a connection point on the server, like USB or Firewire ports, with each port serving a specific purpose.
For example:
Web pages are served on port 80 (HTTP), emails are sent via port 25 (SMTP).
Usage
[php]make.socket(host = “localhost”, port, fail = TRUE, server = FALSE)[/php]
Arguments
host name of remote host
port port to connect to/listen on
fail failure to connect is an error?
Server a server socket?
Learn more about Sockets in detail.
Q.95. What is protocol?
A protocol is a set of rules and procedures. It means what format to use, what data mean, when should data be sent. When two computers exchange data, they can understand each other if both follow specific format and rules in a protocol. It is a set of rules and procedures and computers. It is been used to communicate.
Learn more about Protocols in detail.
Q.96. 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.
Q.97. 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.
R interview questions and answers - TCP/IP

R interview questions and answers – TCP/IP

Q.98. What is TCP/IP variable SMC-R storage allocations?

  • Each more RMB that is been allocated for a particular SMC-R link group can accommodate 4 – 32
    more TCP connections, depending on the RCVBFRSIZE value of the TCP connections.
  • More staging buffers are allocated as the volume of application data that is been sent increases.
  • RMBs, staging buffers, and RDMA receive and send elements are all eligible to be deallocated if the volume of application traffic decreases.

Q.99. What is debugging in R?
A grammatically correct program may give us incorrect results due to logic errors. In case such errors (i.e. bugs) occur, we need to find out why and where they occur so that you can fix them. The procedure to identify and fix bugs is called “debugging”.
Learn about R Debugging in detail.

3. Top R Programming Interview Questions

Q.100. What are tools for debugging in R?
There are five toos present for debugging in R respectively:

  • traceback()
  • debug()
  • browser()
  • trace()                                                                                                                                   
  • recover()
R interview questions and answers - Tools for Debugging in R

R interview questions and answers – Tools for Debugging in R

Q.101. What are fundamental principles of debugging?
Programmers often find that they spend more time debugging a program than actually writing it. Good debugging skills are invaluable. There are four basic principles of debugging:

  • The essence of debugging: The principle of confirmation
  • Start Small
  • Debug in a Modular, Top-Down Manner
  • Antibugging
R interview questions - Principles of Debugging

R interview questions – Principles of Debugging

Q.102. What is a Graphic device?
A graphics device is something where we can make a plot to appear. When we make a plot in R, it has to be “sent” to a specific.

  • Window on your computer (screen device) 2. PDF file (file device)
  • PNG or JPEG file (file device)
  • Scalable vector graphics (SVG) file (file device)

The most common place for a plot to be “sent” is the screen device.

  • A Mac, the screen device is launched with the quartz()
  • Windows, the screen device is launched with windows()
  • Unix/Linux, the screen device is launched with x11()
List of Graphics Devices - R interview questions

List of Graphics Devices – R interview questions

Learn more about R Graphic Devices in detail.
Q.103. Explain R graphics devices?
The following devices are currently available:

  • PDF – Write PDF graphics commands to file.
  • xfig – Device for XFIG graphics file format.
  • pictex – Writes TeX/PicTeX graphics commands to a file (of historical interest only).
  • postscript – Writes PostScript graphics commands to a file.
  • bitmap – bitmap pseudo-device via Ghostscript (if available).

The following devices will be functional if R was compiled to use them:

  • png – PNG bitmap device
  • jpeg – JPEG bitmap device
  • bmp – BMP bitmap device
  • tiff – TIFF bitmap device
  • X11 – The graphics device for the X11 windowing system.
  • svg – SVG device based on Cairo graphics.
  • cario.pdf – cairo_ps PDF and PostScript devices based on Cairo graphics.
  • quartz – The graphics device for the macOS native Quartz 2d graphics system.

Q.104. Explain how to save graphs in R?
R runs on so many different operating systems. It supports so many different graphics formats.

  • JPEG – jpeg is been used anywhere but doesn’t resize
  • PNG – png is been used anywhere but doesn’t resize
  • WMF – win.metafile Windows only; best choice with Word; easily resizable
  • PDF – pdf pdflatex; easily resizable
  • Postscript – Postscript latex and Open Office; easily resizable

Q.105. How many methods are there to save graphs?
There are three methods to save graphs respectively:

  • A General method
  • another approach
  • Local Sessions with Windows or OS X
r questions and answers - Methods to Save Graphs in R

r questions and answers – Methods to Save Graphs in R

Learn more about How to Save Graphs in R.
Q.106. What does the term”Dreaded for loop” means?
In R, many questions arise how to accomplish various tasks without for loops. There seems to be a feeling that programmers should avoid these loops at all costs.Those who pose the queries usually have the goal of speeding up their code.
Q.107. Give an example of “Dreaded for loop”?
Ex- Vectorization for speedup
Sometimes, we can use vectorization instead of looping. For example, if x and y are vectors of equal lengths, you can write this:
z <- x + y
This is not only more compact, but even more important, it is faster than using this loop and if we understand the nuts and bolts of vectorization in R, it may help us to write shorter, simpler, safer, and yes, a faster code in the first place.
Q.108. What Is functional programming and memory issues in on the performance basis?

  • Functional Programming – R is a functional programming (FP) language. This means that it provides many tools for the creation and manipulation of functions. In particular, R has what’s known as first-class functions.
  • Memory issues – Most R objects are immutable, or unchangeable. Thus, R operations are implemented as functions that re-assign to the given object, a trait that can have performance implications.

Q.109. What do copy-on-change issues in R?
We will discuss an important feature of R that makes it safer to work with data. Suppose we create a simple numeric vector x1:
[php]x1 <- c(1, 2, 3)[/php]
Then, we assign the value of x1 to x2:
[php]x2 <- x1[/php]
Now, x1 and x2 have exactly the same value. What if we modify an element in one of the two vectors? Will both vectors change?
[php]x1[1] <- 0
x1
## [1] 0 2 3
x2
## [1] 1 2 3[/php]
The output shows that when x1 is changed, x2 will remain unchanged. You may guess that the assignment automatically copies the value and makes the new variable point to the copy of the data instead of the original data.
Q.110. How Using Rprof() to Find Slow Spots in Your Code in R?
If our R code is running unnecessarily slowly, a handy tool for finding the
a) Monitoring with Rprof() – We will call Rprof() to get the monitor started, run our code, and then call Rprof() with a NULL argument to stop the monitoring.
b) Profiling R code – Profiling R code gives you the chance to identify bottlenecks and pieces of code that needs to be more efficiently implemented just by changing one line of the code from
[php]x = data.frame(a = variable1, b = variable2)[/php]
to
[php]x = c(variable1, variable2)[/php]
This big reduction happened because this line of code was called several times during the execution of the function.
c) Using R code profiling functions

  • rprof is a function included in the base package utils, which is loaded by default.
  • To use R profiling in our code, we can call this function and specify its parameters, including the name of the location of the log file that will be written. See the help for rprof for details.
  • Profiling can be turned on and off in your code.

Q.111. What is vectorization in R?
Vectorized functions are a very useful feature of R, but programmers who are used to other languages often have trouble with this concept at first. A vectorized function works not just on a single value, but on a whole vector of values at the same time. But if you understand the nuts and bolts of vectorization in R, it may help you write shorter, simpler, safer, and yes, the faster code in the first place.
Q.112. What is bytecode compilation?
Bytecode objects consist of an integer vector representing instruction opcodes and operands, and a generic vector representing a constant pool. The compiler is implemented almost entirely in R, with just a few support routines in C to manage compiled code objects is called compiler interface.
Q.113. What is the byte in R?
A byte is a data equal to either seven or eight bits depending if it needs error correction (parity)
Q.114. What is JIT in R?
There are two R packages available that offers Just-in-time compilation to R users: the {jit} package and the {compiler} package.
Q.115. What is JIT package?
The {jit} package was created by Stephen Milborrow which provides a just-in-time compilation of R loops and arithmetic expressions in loops, enabling such code to run much faster.
Q.116. What is Preliminaries in R?

  • R is case sensitive
  • # is the comment tag
  • R is installed with a default library/packages. We can add/ import extra Packages to the library using the command library()
  • To use a library function you must load it first into memory using the command load()
  • Basic instructions are memory resident (you do not need to load them)
  • Variable names cannot start with “.” (dot), “+” (plus sign) or “-”(minus sign)
R interview questions and answers - Preliminaries in R

R interview questions and answers – Preliminaries in R

Q.117. How many types of C/C++ preliminaries are present in R?
There are so many types of C/C++ preliminaries are present in R. some of them are mentioned below:

  • Tokens
  • Keywords
  • identifiers
  • Basic datatype
  • User-defined datatype
  • Derived datatype

Q.118. Explain in brief preliminaries of C/C++?
a) Tokens – The smallest individual units in a program are known as tokens. It has the following tokens:

  • Keywords
  • Identifiers
  • Constants
  • Strings
  • Operators

We can write a program in a C++ using tokens, white spaces and the syntax of the language.
i) Keywords – The keyword implements specific C++ language features. They have explicitly reserved identifiers and can’t be used as names for the program variables or other user-defined program elements. Some of the C++ keywords are illustrated; which are in addition to set of ANSI C keywords.

  • Asm
  • Private
  • Protected
  • New
  • Friend
  • Delete
  • Operator
  • inline

ii) Identifiers – Identifiers refer to the names of variables, functions, arrays, classes etc. created by programmers. These are the fundamental need of any language. Each language has its own rules for naming these identifiers. The following rules are common : ( both in C, C++ )

  • Only alphabetic characters, digits and underscores are permitted.
  • The name can’t start with a digit.
  • Uppercase and lowercase letters are distinct.
  • A declared keyword can’t be used as a variable name. However major difference lies in the limit of the length of a name.

b) Basic datatype
C++ compilers support most of the basic data type supported by ANSI C compilers
Char, float, Int, char, double, void. The purpose of the data type void is contrasting. These include

  • specifications of the return type of a function not returning any value.
  • to indicate an empty argument list to a function.
  • The introduction of generic pointers. E.g. void *gp;

c) User-defined datatype
We use user-defined data type structure & union in C while C++ also permits to define another user-defined data type known as class, that can be used to declare variables
d) Derived data type

  • Arrays – In C++ the application of arrays is like that of C only exception being the way the character array is initialized.
  • Functions – The function has undergone major change over in C++. While some of this changes are simple, others just a new way of thinking when organizing our program.Some of these were introduced to make C++ program more readable & reliable
  • Pointers – Pointers are declared & initialized as in C

int x;
int *pi;
pi=&x; etc.
C++ adds the concept of constant pointer & pointer to constant.
e.g. char *const ptr1 = “NEW” // constant pointer
Q.119. How to compile and run code in R?

  • Compiled Code – R is high-level, expressive language.While C and C++ often require more lines of code to solve the same problem, they can be orders of magnitude faster than R.
  • Run the code – We find it easiest to use Rstudio. We can also paste the code in a normal R console or let R run a source file. However, these approaches are a bit less fail-safe.

Q.120. What are debuggers and debugging techniques in R?
To complete a programming project writing code is only the beginning. After the original implementation is complete, it is time to test the program.Hence, debugging takes on great importance: the earlier you find an error, the less it will cost. A debugger allows us, the programmer, to interact and inspect the running program, making it possible to trace the flow of execution and track down the problems.
a) G.D.B. – It is the standard debugger for Linux and Unix-like operating systems.
b) Static Analysis – Searching for errors using psv studio- An introduction to analyzing code to find potential errors via static analysis, using the PVS-Studio tool.
c) Advanced Linux debugging

  • Haunting segmentation faults and pointing errors- Learn how to debug the trickiest programming problems
  • finding memory leaks and other errors with Valgrind- Learn how to use Valgrind, a powerful tool that helps find memory leaks and invalid memory usage.
  • Visual Studio- Visual Studio is a powerful editor and debugger for Windows

Learn more about R Debugging Techniques in detail.
Q.121. How to use R from python?
Calling R from python- First of all, we have to have both R and python installed. we then need to install rpy2. PANDAS recommends that we download version 2.2.x but I have used 2.3.0 without any difficulties. This is not a description of how to use R. This is presented for those that already know R and want to call it from within python to use the advanced PANDAs data manipulation tools.
Q.122. What is string manipulation in R?
Generic programming in an OpenCL program was restricted to using a string manipulation mechanism, where the program was constructed as a string at runtime and then passed to the OpenCL driver fronted, that will finally compile and build the kernel at runtime. Command group that call kernels can also be templated, allowing for a complex position of functors and types.
Learn R String Manipulation in detail.
Q.123. 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()

Learn R String Manipulation functions in detail.
Q.124. What is the regular expression in R string manipulation?
A set of strings will define as regular expressions. We use two types of regular expressions in R, extended regular expressions (the default) and Perl-like regular expressions used by perl = TRUE.
Q.125. What is regular expression syntax?
It specifies characters to seek out, with information about repeats and location within the string. This will practice with the help of metacharacters that have a specific meaning: $ * + . ? [ ] ^ { } | ( ) \
Q.126. What is the Use of String Utilities in the edtdbg Debugging Tool in R string manipulation?
The internal code of the edtdbg debugging tool makes heavy use of string utilities. A typical example of such usage is the dgbsendeditcmd() function:
[php]# send command to editor
dbgsendeditcmd <- function(cmd) {
syscmd <- paste(“vim –remote-send “,cmd,” –servername “,vimserver,sep=””)
system(syscmd)
}[/php]
The main point is that edtdbg sends remote commands to the Vim text editor. For instance, if we are running Vim with a server name of 168 and we want the cursor in Vim to move to line 12, we could type this into a terminal (shell) window:
vim –remote-send 12G –server name 168
The effect would be the same as if you had typed.
This was all on R interview Questions and Answers
Hence, this blog covered the R Interview Questions and answers for both levels i.e R Interview Questions and Answers for Freshers and R Interview Questions and Answers for Experienced.
If you feel any Query in any R Interview Questions, so feel free to share with us. We will be glad to help you out.

Did you like this article? If Yes, please give DataFlair 5 Stars on Google

courses

DataFlair Team

The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.

2 Responses

  1. Manish Nair says:

    Thanks for sharing such an informative blog.

  2. Shahnawaz says:

    Thanks so much for sharing…It will very helpful to krack the interview for beginner and experienced people as well

Leave a Reply

Your email address will not be published. Required fields are marked *