Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

R language interview questions


May 12, 2021 R language tutorial



Dear reader, these R-language interview questions are specifically designed so that you can respond to questions that may be asked in an R-language-related interview. In my experience, a good interviewer has little intention of asking any particular question in your interview, usually starting with the following questions to further develop.


What is R language programming?

The R language is a programming language for statistical analysis and the creation of graphics for this purpose. I t is not a data type, it has a data object for calculation. It is used in areas such as data mining, regression analysis, probability estimation, and many of the packages available.

What are the different data objects in the R language?
They are six data objects in the R language. They are vectors, lists, arrays, matrices, data frames, and tables.

What makes a valid variable name in the R language?
A valid variable name consists of letters, numbers, and points, or underscore characters. The variable name begins with a letter or a point that is not followed by a number.

What are the main differences between arrays and matrices?
The matrix is always two-dimensional because it only has rows and columns. H owever, an array can have any number of dimensions, and each dimension is a matrix. For example, a 3x3x2 array represents two matrices with a dimension of 3x3.

Which data object in the R language is used to store and process classified data?
Factor data objects in the R language are used to store and process classified data in the R language.

How do I load and use csv files in the R language?
The csv file can be .csv the R language ead and other functions. The R language creates data frames when using this function to read csv files.

How do I get the name of the current working directory in the R language?
The command getwd() gives the current working directory in the R-language environment.

What is an R-language Base Pack?
This is the package that loads by default when the R-environment is set. It provides basic functions in the R language environment, such as input/output, arithmetic calculations, and so on.

How do I use the R language in logical regression?
Logical regression processing measures the probability of a binary response variable. In the R language, the function glm() is used to create a logical regression.

How do I access elements in columns 2 and 4 of a matrix named M?

The expression M (4,2) gives the elements of rows 4 and 2.


What is the collection of elements in a vector? Take, for example.
When two vectors of different lengths are involved in an operation, elements of shorter vectors are reused to complete the operation. T his is called an element loop. E xamples -v1 and lt;-c (4, 1, 0, 6) and V2-lt;-c (2,4), v1 and v2 are given (8,4,0,24). Repeat components 2 and 4.

What are the different ways to call functions in the R language?
We can call a function in the R language in three ways. T he first method is called by using the position of the argument. The second method id is called by using the name of the argument, and the third method is called by default.

What is a delay function evaluation in the R language?
The deferred evaluation of a function means that parameters are evaluated only if it is used inside the function body. If there is no reference to an argument in the function body, it is simply ignored.

How do I install a package in the R language?
To install a package in the R language, we use the following command.

install.packages("package Name"
Name the R language pack used to read the XML file.
A package called "XML" is used to read and process XML files.

Can we update and delete any elements in the list?
We can update any element, but we can only delete the element at the end of the list.

Create a matrix for the general expression in the R language.
The general expression for creating a matrix in the R language is - matrix (data, nrow, ncol, byrow, dimnames)

Is this function used to create boxplot graphics in the R language?
The boxplot() function is used to create a boxplot in the R language. It uses formulas and data frames as input to create a box chart.

What does the fR language equency mean in the ts() function when doing time series analysis?
Frequency 6 indicates that the interval between time series data is one hour every 10 minutes.

What is data remodeling in the R language?
In the R language, data objects can be converted from one form to another. F or example, we can create data frames by combining many lists. T his involves a series of R-language commands to bring the data into the new format. This is called data shaping.

What is the output of the R language ununif(4)?
It generates four random numbers between 0 and 1.

How do I get a list of all the packages installed in the R language?
Use commands
installed.packages()


Run command - what does strsplit (x, "e") mean?
It splits the string in vector x into substrings at the position of the letter e.

Give an R script to extract all the only words capitaled from the string - "Fast brown fox skip lazy dog".
x <- “快速的棕色狐狸跳过懒惰的狗”
split.string <- strsplit(x,"")
extract.words <- split.string [[1]]
result <- unique(tolower(extract.words))
print(result)

Vector v is c (1, 2, 3, 4), list x is list (5:8), and what is the output of v x s1?
Error in v x s1: Non-numeric parameters of the binary operator

Vector v is c (1, 2, 3, 4), list x is list (5:8), and what is the output of v x ?
[1] 5 12 21 32s

What is unlist()?
It converts the list to vectors.

Give R-language expressions and get 26 or fewer heads from 51 coins that use pbinom.
x <- pbinom(26,51,0.5)
print(x)
X是向量c(5,9.2,3,8.51NA),mean(x)的输出是什么?
NA

How do I convert data from a JSON file to a data frame?
Using the function as.data.frame()

Give a function in the R language that replaces all the missing values of vector x with the element of the vector?
function(x){x [is.na(x)] <sum(x,na.rm = TRUE); x }


What is the purpose of apply() in the R language?
It is used to apply the same function to each element in the array. For example, look for the average of rows in each row.

Is an array called a matrix or a matrix called an array?
Each matrix can be called an array, but not the other way around. The matrix is always two-dimensional, but the array can be any dimension.

How do I find a help page for missing values?
? NA

How do I get the standard deviation of vector x?
sd(x,na.rm = TRUE)

How do I set the path to the current working directory in the R language?
setwd("Path")

What's the difference between "%%" and "%/%"?
"%%" gives the remaining part of the divide between the first vector and the second vector, while "%/%" gives the trade-in between the first vector and the second vector.

What .max (x) is col?
Look for the maximum value that the column has per row.

Gives the command to create a histogram.
hist()

How do I remove vectors from the R-language workspace?
rm(x)

List the datasets available in the package MASS
data(package ="MASS")

List the datasets available in all available packages.
data(package = .packages(all.available = TRUE))


What is the use of commands - install.packages (file.choose(), repos s NULL)?
It is used to install the R language pack from the local directory by browsing and selecting files.

Gives a command to check if element 15 exists in vector x.
15%在%x

Gives the syntax for creating a scatterpic matrix.
pairs(formula, data)
The formula represents the series of variables used in pairs, and the data represents the dataset from which the variables are obtained.

What is the difference between the subset() function and the sample() function in the R language?
The subset() function is used to select variables and observations. The sample() function is used to select a random sample of n size from the data set.

How do I check that "m" is a matrix data object in the R language?
is.matrix(m) should re-run TRUE.

What is the output of the following expression all (NA? NA)?
[1] NA

How do I get a transply of a matrix in the R language?
The function t() is used to transply the matrix. Example -t(m), where m is the matrix.

What is the use of the "next" statement in the R language?
The "next" statement in the R programming language is useful when we want to skip the current iteration of the loop without terminating it.