R Programing Interview Questions

1 .

Broadly speaking these are Data Structures available in R :

Data Structure |
Description |

Vector |
A vector is a sequence of data elements of the same basic type. Members in a vector are called components. |

List |
Lists are the R objects which contain elements of different types like − numbers, strings, vectors or another list inside it. |

Matrix |
A matrix is a two-dimensional data structure. Matrices are used to bind vectors from the same length. All the elements of a matrix must be of the same type (numeric, logical, character, complex). |

Dataframe |
A data frame is more generic than a matrix, i.e different columns can have different data types (numeric, character, logical, etc). It combines features of matrices and lists like a rectangular list. |

R programming Language |
Python programming language |

Model Building is similar to Python | Model Building is similar to R. |

Model Interpretability is good | Model Interpretability is not good |

Production is not better than Python. | Production is good |

R has good community support over Python. | Community Support is not better than R |

Data Science Libraries are same as Python. | Data Science Libraries are same as R. |

R has good data visualizations libraries and tools | Data visualization is not better than R |

R has a steep learning curve. | Learning Curve in Python is easier than learning R. |

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:

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.`house<-read.csv("C:/Users/John/Desktop/house.csv")`

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.

There are the following packages which are used for data imputation

In iris dataset, there are **five columns**, i.e.,

**Sepal.Length, Sepal.Width, Petal.Length, Petal.Width and Species**

. We will calculate the mean of Sepal-Length across different species of iris flower using the **mean()**

function from the mosaic package.**mean(iris$Sepal.Length~iris$Species)**

A valid variable name consists of letters, numbers and the dot or underline characters. The variable name starts with a letter or the dot not followed by a number.

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**

.