R

The R programming questions and answers in this lesson will help you understand the types of R questions you can expect in data science interviews.

What are the limitations of R?

R has many limitations, but some directly affect data analysis. These limitations are as follows:

  • It needs to load all data into memory (RAM), so it is not appropriate for big data analysis.

  • Processing in R is slower than in other programming tools, and if the package's maintainer no longer sustains its package, then some R scripts do not work with the newer version of R.

What is the difference between Inf and NaN?

The Inf keyword represents the infinity value. For example, if we divide 1 by 0, we get infinity. If we add infinity to infinity, we get infinity. But if we subtract infinity from infinity, we don't get infinity. There is no value defined for this subtraction. That means if a number can't represent a value, it is referred to as NaN (not a number) in R.

Note: When you practice R, you will see NaN if you make a mistake in your code that does not make sense.

What is the use of the with and by functions in R?

The with function applies an expression to a dataset. For example, suppose we have a data frame called newdata that has one group variable and one dependent variable y, then the with function can be used to apply the one-way analysis of variance on the data frame as follows:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.