Thu Jul 19 2018

R language interview questions

R language interview questions

R is a programming language which can be as useful as you want it to be. It used for multiple purposes such as statistical analysis, data visualization, data manipulation, predictive modeling, forecast analysis and the list goes on. R is used by the top companies such as Google, Facebook, and Twitter. The companies take job interviews to hire a good R programmer. They always are ready to pay for the right candidate. To make those interviews easy for you, here we are going to highlight some essential R language related interview questions that give you an idea of the type of questions which may be asked in interviews. So, let's check out the questions answers -

Q. What is R Programming?

Ans. R is a programming language meant for statistical analysis and creating graphs for this purpose. Instead of data types, it has data objects which are used for calculations. It is used in the fields of data mining, Regression analysis, Probability estimation etc., using many packages available in it.

Q. How the data can import in R language?

Ans. R provides to import data in R language. To begin with the R commander GUI, the user should type the commands in the command Rcmdr into the console. Data can be imported in such ways as - select the data set in the dialog box or enter the name of the dataset as required. The data is entered directly using the editor of R Commander via Data->New Data Set. Data also can be imported from a URL or from the plain text file (ASCII), or from any statistical package or from the clipboard.

Q. What are the different data objects in R?

Ans. There are 6 data objects in R. They are vectors, lists, arrays, matrices, data frames, and tables.

Q. How R commands are written?

Ans. By using # at the starting of the line of code like #division commands are written.

Q. What is GUI in R?

Ans. GUI stands for Graphical User Interfaces. R is a command line driven program. The user enters commands at the prompt ( > by default ) and each command is executed one at a time. There have been a number of attempts to create a more graphical interface, ranging from code editors that interact with R, to full-blown GUIs that present the user with menus and dialog boxes.

Q. What is the main difference between an Array and a matrix?

Ans. A matrix is always two dimensional as it has only rows and columns. But an array can be of any number of dimensions and each dimension is a matrix. For example, a 3x3x2 array represents 2 matrices each of dimension 3x3.

Q. What is the best way to communicate the results of data analysis using R language?

Ans. The best possible way to do this is to combine the data, code and analysis results in a single document using knitr for reproducible research. This helps others to verify the findings, add to them and engage in discussions. Reproducible research makes it easy to redo the experiments by inserting new data and applying it to a different problem.

Q. How can you load and use CSV file in R?

Ans. A CSV file can be loaded using the read.csv function. R creates a data frame on reading the CSV files using this function.

Q. What is with () and BY () functions used for?

Ans. With () function is used to apply an expression for a given dataset and BY () function is used for applying a function each level of factors.

Q. What is R Base package?

Ans. It provides the basic functionalities like input/output, arithmetic calculations etc. in the R environment. The package is loaded by default when R environment is set.

Q. What is CLI in R?

Ans. CLI stands for Command Line Interface. In a command line interface, you type commands that you want to execute and press return.

Q. How R is used in logistic regression?

Ans. In R the function glm() is used to create the logistic regression. Logistic regression deals with measuring the probability of a binary response variable.

Q. What is recycling of elements in a vector?

Ans. When two vectors of different length are involved in a operation then the elements of the shorter vector are reused to complete the operation. This is called element recycling.

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

Ans. 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. What is the best way to use Hadoop and R together for analysis?

Ans. HDFS can be used for storing the data for long-term. MapReduce jobs submitted from either Oozie, Pig or Hive can be used to encode, improve and sample the data sets from HDFS into R. This helps to leverage complex analysis tasks on the subset of data prepared in R.

Q. What is lazy function evaluation in R?

Ans. The lazy evaluation of a function means, the argument is evaluated only if it is used inside the body of the function. If there is no reference to the argument in the body of the function then it is simply ignored.

Q. How can you add datasets in R?

Ans. rbind () function can be used add datasets in R language provided the columns in the datasets should be same.

Q. How do you create log-linear models in R language?

Ans. Using the loglm () function.

Q. What are factor variable in R language?

Ans. Factor variables are categorical variables that hold either string or numeric values. Factor variables are used in various types of graphics and particularly for statistical modeling where the correct number of degrees of freedom is assigned to them.

Q. What is meant by K-nearest neighbor?

Ans. K-Nearest Neighbour is one of the simplest machine learning classification algorithms that is a subset of supervised learning based on lazy learning. In this algorithm, the function is approximated locally and any computations are deferred until classification.

Q. What is reshaping of data in R?

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

Q. What does unlist() do?

Ans. It converts a list to a vector.

Q. What do you understand by element recycling in R?

Ans. If two vectors with different lengths perform an operation –the elements of the shorter vector will be re-used to complete the operation. This is referred to as element recycling.

Q. What is the use of sample and subset functions in R programming language?

Ans. Sample () function can be used to select a random sample of size ‘n’ from a huge dataset.

Subset () function is used to select variables and observations from a given dataset.

Q. What is the purpose of using Next statement in R language?

Ans. If a developer wants to skip the current iteration of a loop in the code without terminating it then they can use the next statement. Whenever the R parser comes across the next statement in the code, it skips evaluation of the loop further and jumps to the next iteration of the loop.

Q. What is the use of apply() in R?

Ans. It is used to apply the same function to each of the elements in an Array. For example, finding the mean of the rows in every row.

Q. What is the difference between subset() function and sample() function in R?

Ans. The subset() functions are used to select variables and observations. The sample() function is used to choose a random sample of size n from a dataset.

Q. What is the difference between library() and require() functions in R language?

Ans. There is no real difference between the two if the packages are not being loaded inside the function. require () function is usually used inside the function and throws a warning whenever a particular package is not found. On the flip side, library () function gives an error message if the desired package cannot be loaded.

Q. What is the use of "next" statement in R?

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

Q. How can you merge two data frames in R language?

Ans. Data frames in R language can be merged manually using cbind () functions or by using the merge () function on common rows or columns.

Q. What is transpose?

Ans. Transpose is used for reshaping of the data which is used for analysis. Transpose is performed by t() function.

Q. How data is aggregated in R?

Ans. There are two methods that are collapsing data by using one or more BY variable and other is aggregate() function in which BY variable should be in the list.

Q. What is the power analysis?

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

Q. Which method is used for exporting the data in R?

Ans. There are many ways to export the data to other formats like SPSS, SAS, Stata, Excel Spreadsheet.

Q. How impossible values are represented in R?

Ans. In R NaN is used to represent impossible values.

Q. Which function is used for sorting in R?

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

Q. How to create axes in the graph?

Ans. Using axes() function custom axes are created.

Q. Why vcd package is used?

Ans. vcd package provides different methods for visualizing multivariate categorical data.

Q. On which type of data binary operators are worked?

Ans. Binary operators are worked on matrices, vectors, and scalars.

Q. What is power analysis?

Ans. Power analysis is the process used to determine the effect of a given sample size and is generally used for experimental design. Pwr package in R is used for power analysis.

Q. What is npmc?

Ans. It is a package which gives nonparametric multiple comparisons.

Q. What is a robust base?

Ans. It is a package which provides basic robust statistics including model selection methods.

Q. What is the use of MASS package?

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

Q. What is the full form of SEM?

Ans. SEM stands for Structural Equation Modeling.


 

Normally questions start with some basic concept of the subject and later that continue based on further discussion and what you answer. The interviewer may ask other question as they prefer. Hope these gave you an idea of R language questions and help you to understand the label of the interview. Best of luck for the future! Thank you!

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.