## R interview questions and answers 👇

### General

### What is the difference between seq(4) and seq_along(4)?

View answer

Seq(4) means vector from 1 to 4 (c(1,2,3,4)) whereas seq_along(4) means a vector of the length(4) or 1(c(1)).

### What is the power analysis?

View answer

It is used for experimental design .It is used to determine the effect of given sample size.

### What happens when the application object does not handle an event?

View answer

The event will be dispatched to your delegate for processing.

### Explain the purpose of using UIWindow object?

View answer

UIWindow object coordinates the one or more views presenting on the screen.

### What is GGobi?

View answer

GGobi is an open source program for visualization for exploring high dimensional typed data.

### What is the use of lattice package?

View answer

lattice package is to improve on base R graphics by giving better defaults and it have the ability to easily display multivariate relationships.

### Which data structures are used to perform statistical analysis and create graphs.

View answer

Data structures are vectors, arrays, data frames and matrices.

### What is the use of diagnostic plots?

View answer

It is used to check the normality, heteroscedasticity and influential observations.

### Define relaimpo package.

View answer

It is used to measure the relative importance of each of the predictor in the model.

### Define robust package.

View answer

It provides a library of robust methods including regression.

### Define Survival analysis.

View answer

It includes number of techniques which is used for modeling the time to an event.

### What is the use of MASS package?

View answer

MASS functions include those functions which performs linear and quadratic discriminant function analysis.

### What is the use of forecast package?

View answer

It provides the functions which are used for automatic selection of ARIMA and exponential models.

### What is the full form of CFA?

View answer

CFA stands for Confirmatory Factor Analysis.

### What is clustering? What is the difference between kmeans clustering and hierarchical clustering?

View answer

Cluster is a group of objects that belongs to the same class. Clustering is the process of making a group of abstract objects into classes of similar objects.

Let us see why clustering is required in data analysis:

- Scalability − We need highly scalable clustering algorithms to deal with large databases.
- Ability to deal with different kinds of attributes − Algorithms should be capable of being applied to any kind of data such as interval-based (numerical) data, categorical, and binary data.
- Discovery of clusters with attribute shape − The clustering algorithm should be capable of detecting clusters of arbitrary shape. They should not be bounded to only distance measures that tend to find spherical cluster of small sizes.
- High dimensionality − The clustering algorithm should not only be able to handle low-dimensional data but also the high dimensional space.
- Ability to deal with noisy data − Databases contain noisy, missing or erroneous data. Some algorithms are sensitive to such data and may lead to poor quality clusters.
- Interpretability − The clustering results should be interpret-able, comprehensible, and usable.

### What is kmeans clustering?

View answer

K-means clustering is a well known partitioning method. In this method objects are classified as belonging to one of K-groups. The results of partitioning method are a set of K clusters, each object of data set belonging to one cluster. In each cluster there may be a centroid or a cluster representative. In the case where we consider real-valued data, the arithmetic mean of the attribute vectors for all objects within a cluster provides an appropriate representative; alternative types of centroid may be required in other cases.

Example: A cluster of documents can be represented by a list of those keywords that occur in some minimum number of documents within a cluster. If the number of the clusters is large, the centroids can be further clustered to produce hierarchy within a dataset. K-means is a data mining algorithm which performs clustering of the data samples. In order to cluster the database, K-means algorithm uses an iterative approach.

### What is hierarchical clustering?

View answer

This method creates a hierarchical decomposition of the given set of data objects. We can classify hierarchical methods on the basis of how the hierarchical decomposition is formed. There are two approaches here:

Agglomerative Approach:

This approach is also known as the bottom-up approach. In this, we start with each object forming a separate group. It keeps on merging the objects or groups that are close to one another. It keeps on doing so until all of the groups are merged into one or until the termination condition holds.

Divisive Approach:

This approach is also known as the top-down approach. In this, we start with all of the objects in the same cluster. In the continuous iteration, a cluster is split up into smaller clusters. It is down until each object in one cluster or the termination condition holds. This method is rigid, i.e., once a merging or splitting is done, it can never be undone.

### What is a factor?

View answer

Conceptually, factors are variables in R which take on a limited number of different values; such variables are often referred to as categorical variables. One of the most important use of factors is in statistical modeling; since categorical variables enter into statistical models differently than continuous variables, storing data as factors ensures that the modeling functions will treat such data correctly.

### How can you load a .csv file in R?

View answer

All you need to do is use the “read.csv()” function and specify the path of the file.

house<-read.csv("C:/Users/John/Desktop/house.csv")

### What are the different components of grammar of graphics?

View answer

Broadly speaking these are different components in grammar of graphics:

- Data layer
- Aesthetics layer
- Geometry layer
- Facet layer
- Co-ordinate layer
- Themes layer

### What is Rmarkdown? What is the use of it?

View answer

RMarkdown is a reporting tool provided by R. With the help of Rmarkdown, you can create high quality reports of your R code.

The output format of Rmarkdown can be:

- HTML
- WORD

### Name some packages in R, which can be used for data imputation?

View answer

These are some packages in R which can used for data imputation

- MICE
- Amelia
- missForest
- Hmisc
- Mi
- imputeR

### Name some functions available in “dplyr” package.

View answer

Functions in dplyr package:

- filter
- select
- mutate
- arrange
- count

### What packages are used for data mining in R?

View answer

Some packages used for data mining in R:

- data.table- provides fast reading of large files.
- rpart and caret- for machine learning models.
- Arules- for associaltion rule learning.
- GGplot- provides varios data visualization plots.
- tm- to perform text mining.
- Forecast- provides functions for time series analysis.

### What is t-tests() in R?

View answer

It is used to determine that the means of two groups are equal or not by using t.test() function.

### What is the use of subset() and sample() function in R?

View answer

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 is the memory limit of R?

View answer

In 32 bit system memory limit is 3Gb but most versions limited to 2Gb and in 64 bit system memory limit is 8Tb.

### How impossible values are represented in R?

View answer

In R NaN is used to represent impossible values.

### Which function is used for sorting in R?

View answer

order() function is used to perform the sorting.