R Programming Interview Questions and Answers Set 7

61. How can you load and use csv file in R?

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

62. What is the recycling of elements in a vector? Give an example.

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. Example – v1 <- c(4,1,0,6) and V2 <- c(2,4) then v1*v2 gives (8,4,0,24). The elements 2 and 4 are repeated.

63. Which function is used to create a boxplot graph in R?

The boxplot() function is used to create boxplots in R. It takes a formula and a data frame as inputs to create the boxplots.

64. Give the syntax for creating scatterplot matrices.

pairs(formula, data)

Where formula represents the series of variables used in pairs and data represents the data set from which the variables will be taken.

65. What is Descriptive analysis in R?

It does exactly what the name Implies “Describe”. it allows us to learn from our past and to understand how they might influence future outcomes. The main goal of is to find out the reasons behind previous success or failure in the past. Hence, Most of the social analysis is descriptive analysis. For Example – the company’s production, financials, operations, sales, finance, inventory, and customers.


Weekend / Weekday Batch


66. What is an Atomic vector and how many types of atomic vectors are present in R?

The atomic vector is the simplest R data type. Atomic vectors are linear vectors of a single primitive type, like an STL Vector in C++. There are four types of atomic vectors are present in R:

  • Numerical datatype
  • Integer datatype
  • Character datatype
  • Logical datatype

67. Name the functions which help in importing data from other applications in R?

  • table()
  • readlines()
  • fwf
  • delim()
  • scan()
  • csv()
  • csv2()

68. What are vector functions?

In R, a function is a piece of code written to carry out a specified task. R Functions are called as objects because we can work with them exactly the same way we work with any other type of object. Vector functions are those functions which we used in vectors.
For Example: rep(), seq(), using all() and any(), more on c() etc.

Most common functions which we use in vector operations are

  • rep()
  • seq()

69.  How many data structures R has?

There are 5 data structure in R i.e. vector, matrix, array which are of a homogeneous type and other two are list and data frame which are heterogeneous.

70. Explain how to save graphs in R?

R runs on so many different operating systems. It supports so many different graphics formats.

  • JPEG – jpeg is been used anywhere but doesn’t resize
  • PNG– png is been used anywhere but doesn’t resize
  • WMF– win. metafile Windows only; best choice with Word; easily resizable
  • PDF– pdf pdflatex; easily resizable
  • Postscript– Postscript latex and Open Office; easily resizable