R Language interview questions

R Language quiz questions

  • 1.

    If you want to know all the values in c (1, 3, 5, 7, 10) that are not in c (1, 5, 10, 12, 14). Which in-built function in R can be used to do this? Also, how this can be achieved without using the in-built function.

    Answer:

    Using in-built function - setdiff(c (1, 3, 5, 7, 10), c (1, 5, 10, 11, 13))

    Without using in-built function - c (1, 3, 5, 7, 10) [! c (1, 3, 5, 7, 10) %in% c (1, 5, 10, 11, 13).

    View
  • 2.

    What will be the class of the resulting vector if you concatenate a number and a character?

    Answer:

    character

    View
  • 3.

    What is meant by K-nearest neighbour?

    Answer:

    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.

    View
  • 4.

    What will be the class of the resulting vector if you concatenate a number and NA?

    Answer:

    number

    View
  • 5.

    How do you create log linear models in R language?

    Answer:

    Using the loglm () function

    View
  • 6.

    What are the data types in R on which binary operators can be applied?

    Answer:

    Scalars, Matrices ad Vectors.

    View
  • 7.

    What is the memory limit in R?

    Answer:

    8TB is the memory limit for 64-bit system memory and 3GB is the limit for 32-bit system memory.

    View
  • 8.

    What are factor variable in R language?

    Answer:

    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 modelling where the correct number of degrees of freedom is assigned to them.

    View
  • 9.

    How can you add datasets in R?

    Answer:

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

    View
  • 10.

    What is the difference between data frame and a matrix in R?

    Answer:

    Data frame can contain heterogeneous inputs while a matrix cannot. In matrix only similar data types can be stored whereas in a data frame there can be different data types like characters, integers or other data frames.

    View
  • 11.

    Which package in R supports the exploratory analysis of genomic data?

    Answer:

    adegenet

    View
  • 12.

    What will be the output of the below code -

    Answer:

    printmessage <- function (a) {
    
                      if (is.na (a))
    
                                 print ("a is a missing value!")
    
                         else if (a < 0)
    
                                 print ("a is less than zero")
    
                         else
    
                                print ("a is greater than or equal to zero")
    
                        invisible (a)
    
     }
    
    printmessage (NA)
    

    The output for the above R programming code will be “a is a missing value.” The function is.na () is used to check if the input passed is a missing value.

    View
  • 13.

    How is a Data object represented internally in R language?

    Answer:

    unclass (as.Date (“2016-10-05″))

    View
  • 14.

    What will be the output of log (-5.8) when executed on R console?

    Answer:

    Executing the above on R console will display a warning sign that NaN (Not a Number) will be produced because it is not possible to take the log of negative number.

    View
  • 15.

    What is the best way to use Hadoop and R together for analysis?

    Answer:

    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.

    View
  • 16.

    What is the command used to store R objects in a file?

    Answer:

    save (x, file=”x.Rdata”)

    View
  • 17.

    What are the different type of sorting algorithms available in R language?

    Answer:

    Bucket Sort

    Selection Sort

    Quick Sort

    Bubble Sort

    Merge Sort

    View
  • 18.

    In base graphics system, which function is used to add elements to a plot?

    Answer:

    boxplot () or text ()

    View
  • 19.

    dplyr package is used to speed up data frame management code. Which package can be integrated with dplyr for large fast tables?

    Answer:

    data.table

    View
  • 20.

    What are with () and BY () functions used for?

    Answer:

    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.

    View

© 2017 QuizBucket.org