June 17, 2019

Srikaanth

ServiceNow R Programming Recently Asked Interview Questions

ServiceNow R Programming Recently Asked Interview Questions Answers

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.

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.
ServiceNow R Programming Recently Asked Interview Questions Answers
ServiceNow R Programming Recently Asked Interview Questions Answers

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.

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.

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.

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.

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.

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.

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

Explain how to create a list in R?

Create a list containing string, numbers, vectors and logical values. For Example:

List_data <- list("Green", "Yellow", c(5,6,7), TRUE, 51.2)

print(list_data) When we execute the above code, it produces the following result-

[[1]]
[1] “Green”
[[2]]
[1] “Yellow”
[[3]]
[1] 5, 6, 7
[[4]]
[1] TRUE
[[5]]
[1] 51.2


How to use sapply in R?

Multipy all values by 10:

> sapply(BOD,function(x) 10 * x)
Time demand
[1,] 10 80
[2,] 20 100
[3,] 30 190
Used for array, margin set to 1:

> x <- array(1:9) > sapply(x,function(x) x * 10)
[1] 10 20 30 40 50 60 70 80 90
Two dimension array, margin can be 1 or 2:

> 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
sapply: returns a vector, matrix or an array
# sapply : returns a vector, an array or matrix

sapply(c(1:3), function(x) x^2)
[1] 1 4 9

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.

Name all control statements present in R?

If
If-else
For
Nested loops
While
Repeat and break
Next
return.

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:

print(list_data[1])

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

Print(list_data[3])

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”
$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.


Subscribe to get more Posts :

1 comments:

Write comments
Unknown
AUTHOR
August 17, 2020 at 12:31 PM delete

Thanks for sharing valuable information and very well explained . Keep posting.

servicenow course online
servicenow online training in India

Reply
avatar