**Q.**1. Explain the data import in R language.**A.**R provides to import data in R language. To begin with the R commander GUI, user should type the commands in the command Rcmdr into the console. Data can be imported in R language in 3 ways such as:- Select the data set in the dialog box or enter the name of the data set as required.
- Data is entered directly using the editor of R Commander via Data->New Data Set. This works good only when the data set is not too large.
- Data can also be imported from a URL or from plain text file (ASCII), or from any statistical package or from the clipboard.

Go through the R Programming Video to get clear understanding of R.

**Q.**2. Explain how to communicate the outputs of data analysis using R language.**A.**Combine the data, code and analysis results in a single document using knitr for Reproducible research done. Helps to verify the findings, add to them and engage in conversations. Reproducible research makes it easy to redo the experiments by inserting new data values and applying it to different various problems.

**Q.**3.What is R?**A.**R is a programming language which is used for developing statistical software and data analysis. It is being increasingly deployed for machine learning applications as well.

**Q.**4.What are the disadvantages of R Programming?**A.**The disadvantages are:-- Lack of standard GUI
- Not good for big data.
- Does not provide spreadsheet view of data.

**Q.**5. What is the use of With () and By () function in R?**A.**with() function applies an expression to a dataset.

#with(data,expression)

By() function applies a function t each level of a factors.

#by(data,factorlist,function)

**Q.**6. What is the use of subset() and sample() function in R?**A.**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.

**Q.**7. What are the advantages of R?**A.**The advantages are:-- It is used for managing and manipulating of data.
- No license restrictions
- Free and open source software.
- Graphical capabilities of R are good.
- Runs on many Operating system and different hardware and also run on 32 & 64 bit processors etc.

**Q.**8. What is the function used for adding datasets in R?**A.**For adding two datasets rbind() function is used but the column of two datasets must be same.

`Syntax: rbind(x1,x2……) where x1,x2: vector, matrix, data frames.`

**Q.**9. How many data structures R has?**A.**There are 5 data structure in R i.e. vector, matrix, array which are of homogenous type and other two are list and data frame which are heterogeneous.

**Q.**10.How many sorting algorithms are available?**A.**There are 5 types of sorting algorithms are used which are:-- Bubble Sort
- Selection Sort
- Merge Sort
- Quick Sort
- Bucket Sort

**Q.**11.How to create new variable in R programming?**A.**For creating new variable assignment operator ‘<-’ is used

For e.g. mydata$sum <- mydata$x1 + mydata$x2

**Q.**12.What are R packages?**A.**Packages are the collections of data, R functions and compiled code in a well-defined format and these packages are stored in library. One of the strengths of R is the user-written function in R language.

**Q.**13. What is the function which is used for merging of data frames horizontally in R?**A.**Merge()function is used to merge two data frames

Eg. Sum<-merge(data frame1,data frame 2,by=’ID’)

**Q.**14. What is fitdistr() function?**A.**It is used to provide the maximum likelihood fitting of univariate distributions. It is defined under the MASS package.

**Q.**15. What is FactoMineR?**A.**It is a package which includes quantitative and qualitative variables. It also includes supplementary variables and observations.

**Q.**16. Why does widget not show up in the sidebar?**A.**While using a widget, you have to ensure whether your theme supports the widget and if it does then, it must show the sidebar. If in any case if it happens that you don’t see the sidebar, then it might be missing the “function.php” file or file similar to that. This can also happen if you have forgotten to save the changes in the widget or to refresh the older display of the page.

**Q.**17. How can you load a .csv file in R?Loading a .csv file in R is quite easy. All you need to do is use the “read.csv()” function and specify the path of the file.**A.**`house<-read.csv("C:/Users/John/Desktop/house.csv")`

**Q.**18. What are the different components of grammar of graphics?Broadly speaking these are different components in grammar of graphics:**A.**- Data layer
- Aesthetics layer
- Geometry layer
- Facet layer
- Co-ordinate layer
- Themes layer

**Q.**19. What are the different components of grammar of graphics?Broadly speaking these are different components in grammar of graphics:**A.**- Data layer
- Aesthetics layer
- Geometry layer
- Facet layer
- Co-ordinate layer
- Themes layer

**Q.**20. How do you install a package in R?The below command is used to install a package in R:**A.**`install.packages(“<package_name>”)`

let’s look at an example:

**Q.**21. 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:**A.**- HTML
- WORD

**Q.**22. Name some packages in R, which can be used for data imputation?These are some packages in R which can used for data imputation**A.**- MICE
- Amelia
- missForest
- Hmisc
- Mi
- imputeR

**Q.**23. Name some functions available in “dplyr” package.Functions in dplyr package:**A.**- filter
- select
- mutate
- arrange
- count

**Q.**24. Tell me something about shinyR.Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in Rmarkdown documents or build dashboards. You can also extend your Shiny apps with CSS themes, htmlwidgets, and JavaScript actions.**A.**

**Q.**25. What is advantage of using apply family of functions in R?The apply function allows us to make entry-by-entry changes to data frames and matrices.The usage in R is as follows:**A.**apply(X, MARGIN, FUN, …)

where:

X is an array or matrix;

MARGIN is a variable that determines whether the function is applied over rows (MARGIN=1), columns (MARGIN=2), or both (MARGIN=c(1,2));

FUN is the function to be applied.

If MARGIN=1, the function accepts each row of X as a vector argument, and returns a vector of the results. Similarly, if MARGIN=2 the function acts on the columns of X. Most impressively, when MARGIN=c(1,2) the function is applied to every entry of X.

Advantage:

With the apply function we can edit every entry of a data frame with a single line command. No auto-filling, no wasted CPU cycles.

**Q.**26. What packages are used for data mining in R?Some packages used for data mining in R:**A.**- 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

**Q.**27. What do you know about the rattle package in R?**A.****Rattle**is a popular GUI for data mining using R. It presents statistical and visual summaries of data, transforms data so that it can be readily modelled, builds both unsupervised and supervised machine learning models from the data, presents the performance of models graphically, and scores new datasets for deployment into production.*A key features is that all of your interactions through the graphical user interface are captured as an R script that can be readily executed in R independently of the Rattle interface.*

**Q.**28. How would you fit a linear model over a scatter-plot?We can do that using the “ggplot2” package.We’ll first make a scatter-plot with the help of geom_point() function, then we’ll make the linear model, by adding the geom_smooth() layer on top of it.**A.**data, presents the performance of models graphically, and scores new datasets for deployment into production.*A key features is that all of your interactions through the graphical user interface are captured as an R script that can be readily executed in R independently of the Rattle interface.*

**Q.**29. What are the different import functions in R?Data from different sources and different formats can be imported into R. Let’ have a look at the different import functions available in R:**A.**- read.csv()-> for reading .csv files
- read_sas()-> for reading .sas7bdat files
- read_excel()-> for xl sheets
- read_sav()-> for spss data

**Q.**30. Name some functions which can be used for debugging in R?These are some functions which can be used for debugging in R:**A.**- traceback()
- debug()
- browser()
- trace()
- recover()

**Q.**31. What are the objects you use most frequently?This question is meant to gather a sense of your experiences in R. Simply think about some recent work you’ve done in R and explain the data objects you use most often. If you use arrays frequently, explain why and how you’ve used them.**A.**

**Q.**32. What are some of your favorite functions in R?As a user of R, you should be able to come up with some functions on the spot and describe them. Functions that save time and, as a result, money will always be something an interviewer likes to hear about.**A.**

**Q.**33. What are 3 sorting algorithms available in R?R uses the**A.**`sort()`

function to order a vector or factor, listed and described below.**Radix**: Usually the most performant algorithm, this is a non-comparative sorting algorithm that avoids overhead. It’s stable, and it’s the default algorithm for integer vectors and factors.**Quick Sort:**This method “uses Singleton (1969)’s implementation of Hoare’s Quicksort method and is only available when x is numeric (double or integer) and partial is NULL,” according to R Documentation. It’s not considered a stable sort.**Shell:**This method “uses Shellsort (an O(n4/3) variant from Sedgewick (1986)),” according to R Documentation.

**Q.**34. Why is R useful for data science?R turns otherwise hours of graphically intensive jobs into minutes and keystrokes. In reality, you probably wouldn’t encounter the language of R outside the realm of data science or an adjacent field. It’s great for linear modeling, nonlinear modeling, time-series analysis, plotting, clustering, and so much more.Simply put, R is designed for data manipulation and visualization, so it’s natural that it would be used for data science.**A.**

**Q.**35. What is reshaping of data in R?In R the data objects can be converted from one form to another. For example we can create a data frame by merging many lists. This involves a series of R commands to bring the data into the new format. This is called data reshaping.**A.**