## R interview questions and answers ๐

### General

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

โ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?

โ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?

โThe event will be dispatched to your delegate for processing.

#### Explain the purpose of using UIWindow object?

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

#### What is GGobi?

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

#### What is the use of lattice package?

โ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.

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

#### What is the use of diagnostic plots?

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

#### Define relaimpo package.

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

#### Define robust package.

โIt provides a library of robust methods including regression.

#### Define Survival analysis.

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

#### What is the use of MASS package?

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

#### What is the use of forecast package?

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

#### What is the full form of CFA?

โCFA stands for Confirmatory Factor Analysis.

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

โ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?

โ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?

โ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?

โ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?

โ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?

โ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?

โ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?

โ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.

โFunctions in dplyr package:

- filter
- select
- mutate
- arrange
- count

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

โ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?

โ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?

โ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?

โ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?

โIn R NaN is used to represent impossible values.

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

โorder() function is used to perform the sorting.