# R Programming Interview Questions and Answers Categories

###### R Programming ## Top R Programming Interview Questions and Answers - 2021 [UPDATED]

Are you looking for R Programming Interview Questions and Answers? Than you are at the Right Place. Browse through Popular and Most Asked Interview Questions for R Programming.  There is a Huge Demand for R Programming Professionals in the Market. These Questions are suitable for both Freshers and Experienced Professionals and are based on Trending Topics and as per Current Industry Requirements.

Master These Topics and Increase your Chances in cracking R Programming Interviews like a pro and Secure your Dream Job Today.

#### R Programming Interview Questions and Answers

• 49 Questions

Arithmetic Operators Rational Operators Logical Operators Assignment operators

Addition, Subtraction, Multiplication, Division are the basic arithmetic operators. In R, it is generally used to declare using with same representations as +, -, *, / respectively. Apart from this, we have %%, which gives the remainder value & ^ to an exponent.

<, >, <=, >= ==, != are the relational operators where the first vector is against the second vector in R.

R supports 3 Logical operators. Where & refers the AND operator, | refers the OR operator and ! represents the NOT operator.

Assignment operators have 2 ideas of assignment. Left assignment operators & Right assignment operators. = cannot be used as the right assignment operator. Left assignment operators are: <- | <<- | = Right assignment operators are: -> | ->>

It helps to create a sequence. When a sequence has to be declared, : operator is being utilized. Example: 1:10, will result in 1 2 3 4 5 6 7 8 9 10.

IF, IF_ELSE, Switch are the 3 decision statements in R.

In R, we have FOR, WHILE & REPEAT loops. Loops help to make the certain executions repetitive for the given conditions.

R is a statistical language which is hardcore for any statistical analysis. It doesn’t support general developments like other languages, such as Python & Java.

A vector can be of any dimensions. Even any variables saved with 1 value, it becomes a vector. Greater than 1 dimension, vectors can be created using the function c(). Example: A = 1:5 results 1 2 3 4 5. A = c(1,2) results 1 2.

No, the data types will be coerced. If it is a vector with few numeric data points and if any one data point is a character, vector will be coerced to character data type.

Yes, all arithmetic operations are possible in a vector.

If the two vectors are of unequal lengths, the vector which is less in length will be repeated until the operation is getting performed. Example: a = c(1,2) | 1 2 # a becomes 1 2 1 2 b = c(3:6) | 3 4 5 6 a+b | 4 6 6 8

DMwR stands for Data Manipulation with R. Where this package is one of the widely used package for any data manipulations.

Lubridate. This package is widely used for any data analysis on the date. It includes dates processing of seconds, minutes & hours with predefined functions of s, m, and h respectively.

Yes, a list is editable in R. List is one of the widely used objects in R. Where it can have multiple data types within one list. Not like vector, which doesn’t support multiple data types within one vector. List can have a list within a list.

Yes. A list can be converted into a vector. UNLIST is a predefined function which converts a list to the vector. This function delists a list and produces output as a vector. Example: sample_List = list(1:5) |  1 2 3 4 5 unlist(sample_list) | 1 2 3 4 5

Matrix & Data frame has a similar structural object. But data frame can have different data types in the different column. Where matrix cannot have different data types.

Yes, all arithmetic operations are possible in a matrix.

Factor is an object in R, which converts a vector to a categorizable object level. Which it can have N levels.

str() – Will get the structure of the data frame summary() – will give you the summary of the data frame. The summary function gives you the MIN, MAX, MEAN, 1st, 2nd, 3rd

rbind() – It merges the two data frames by row level in the data cbind() – It merges the two different data frames by column level in the data.

MAX – It will give you the maximum value of the data. Eg: max(data_frame\$Column_name) MIN – It will give you the minimum value of the data. Eg: min(data_frame\$Column_name)

read_csv() – this function reads the data to R. write.csv() – this function writes the data from R.

Yes, dbConnect() – function can be used to connect the MySQL. dbSendQuery() – this function helps SQL query to be applied in R to get those query results in R.

Vector List Array Matrix Tables Data frame

RMD files help to create a better reporting portable code file. RMD helps to generate the HTML file which can be transferred which doesn’t demand data for processing.

R shiny is a package which helps to generate the web application from R. It does support the CSS, Java-script integrations.

str_count() – this function helps to count the number of strings in the variable or in the vector.

mean() – this function calculates mean value. median() – this function calculates the median value. Unlike mean & median, we don’t have a pre-defined function in R for Mode. We must derive it for our own.

lm() – this function helps us to build a linear regression model, which results from the slope and intercept values of the model.

Linear regression function(lm()) uses stats package in R. Linear regression included in the machine learning family, but it is just a statistical idea, where it helps to predict. Technically it is not a machine learning model.

plot(x,y) – this function will create a scatter plot in R. It needs to get 2 parameters given, both should be numeric.

No, normal data cannot parse directly. Data has to be converted into a time series data using ts() function in R.

if yes, name the functions. Yes, Join functions are possible in R. left_join() – this performs the left join right_join() – this performs the right join inner_join() – this performs the inner join full_join() – this performs the full join

colnames() – this function will result from the column names of a data frame.

R will support 3GB memory if it is a 32-bit processor and it is a 64-bit processor, It does support till 8TB. Q38) What correlation is being used in R? what is the function to get a correlation in R? R uses Pearson correlation in default. Cor() – function gives the correlation between the columns. Pearson correlation cannot be applied for a categorical column.

No, R doesn’t support reverse indexing. Rather, if you use – with index, it drops it.

Install.packages() – will install package to your local system from CRAN/Git. installed.packages() – will give the list of packages that have been installed in a local system.

No, it is not possible to do arithmetic operations between two different data types. It will result in the error.

All Matrix can be called as the array, but all array cannot be called as Matrix. It is because that, a matrix will always have a 2 dimension, where the array can have any dimension in nature.

GLM() – this function builds a logistic model, we have to make sure the family parameter is BINOMIAL. Because GLM stands for Generalised Linear Models. Where this function can perform other generalized models like Gaussian.

Kmeans() – Performs Kmeans algorithm for the given data, K parameter is a mandate. KmeansPP() – performs Kmeans-Plus-plus algorithm. K parameter is a mandate.

randomForest – To build a random Forest algorithm rpart – To build a CART algorithm C50 – To build a C5.0 algorithm naive Bayes – To build a Naïve Bayes algorithm XP boost – To build an XG boost Algorithm fastAdaboost – To build a Ada Boost algorithm stats – To build both Linear & Logistic regression, models

Yes, we can do transpose the data in R. t() – function will transpose the data in R.

is.na() function will result whether the data point is NA or not. To sum it up and get the number of missing values, we can use both sum & is.na function together to achieve it. sum(is.na(data_frame)) will result from the number of NA values in the data frame.

Yes, you can use read.table() function from utils package to import it.

[] – subsets with Index values subset() – performs with the given condition, includes row names in results filter() – performs with given condition, excludes row names in results select() – performs with the conditions, similar to SQL select statement

setwd() – function sets the current working directory getwd() – function gets the path of the working directory.