Almost all MCQs of Computer

R programming Language Solved MCQs


R Programming Questions and Answers Part-1

1. ____ programming language is a dialect of S.
a) B
b) C
c) R
d) K

Answer: c
Explanation: S was initiated in 1976 as an internal statistical analysis environment—originally implemented as Fortran libraries.

2. Point out the WRONG statement?
a) Early versions of the S language contain functions for statistical modeling
b) The book Programming with Data by John Chambers documents S version of the language
c) In 1993 Bell Labs gave StatSci (later Insightful Corp.) an exclusive license to develop and sell the S language
d) The book Programming with Data by IBM documents S version of the language

Answer: a
Explanation: Insightful sold its implementation of the S language under the product name S-PLUS.

3. In 2004, ________ purchased the S language from Lucent for $2 million.
a) Insightful
b) Amazon
c) IBM
d) TCS

Answer: a
Explanation: TIBCO is the current owner of the S language and is its exclusive developer.

4. In 1991, R was created by Ross Ihaka and Robert Gentleman in the Department of Statistics at the University of _________
a) John Hopkins
b) California
c) Harvard
d) Auckland

Answer: d
Explanation: In 1993 the first announcement of R was made to the public. Ross’s and Robert’s experience developing R is documented in a 1996 paper in the Journal of Computational and Graphical Statistics.

5. Point out the wrong statement?
a) R is a language for data analysis and graphics
b) K is language for statistical modelling and graphics
c) One key limitation of the S language was that it was only available in a commercial package, S-PLUS
d) C is a language for data and graphics

Answer: b
Explanation: In 1996, a public mailing list was created (the R-help and R-devel lists) and in 1997 the R Core Group was formed, containing some people associated with S and S-PLUS.

6. Finally, in _________ R version 1.0.0 was released to the public.
a) 2000
b) 2005
c) 2010
d) 2012

Answer: a
Explanation: Source code for the entire R system is accessible to anyone who wanted to tinker with it.

7. R is technically much closer to the Scheme language than it is to the original _____ language.
a) B
b) C
c) C++
d) S

Answer: d
Explanation: R’s semantics, while superficially similar to S, are quite different.

8. The R-help and _____ mailing lists have been highly active for over a decade now.
a) R-mail
b) R-devel
c) R-dev
d) R-del

Answer: b
Explanation: There is considerable activity on web sites like Stack Overflow as well.

9. Which of the following describes R language?
a) Free
b) Paid
c) Available for free trial only
d) Testing

Answer: a
Explanation: A major advantage that R has over many other statistical packages and is that it’s free.

10. The copyright for the primary source code for R is held by the ______ Foundation.
a) A
b) S
c) C
d) R

Answer: d
Explanation: It is published under the GNU General Public License version.
 

R Programming Questions and Answers Part-2

1. They primary R system is available from the ______
a) CRAN
b) CRWO
c) GNU
d) CRDO

Answer: a
Explanation: CRAN stands for Comprehensive R Archive Network.

2. Point out the wrong statement?
a) Key feature of R was that its syntax is very similar to S
b) R runs only on Windows computing platform and operating system
c) R has been reported to be running on modern tablets, phones, PDAs, and game consoles
d) R functionality is divided into a number of Packages

Answer: b
Explanation: R runs on almost any standard computing platform and operating system.

3. R functionality is divided into a number of ________
a) Packages
b) Functions
c) Domains
d) Classes

Answer: a
Explanation: CRAN also hosts many add-on packages that can be used to extend the functionality of R.

4. Which Package contains most fundamental functions to run R?
a) root
b) child
c) base
d) parent

Answer: c
Explanation: base package in R contains the most fundamental functions.

5. Point out the wrong statement?
a) One nice feature that R shares with many popular open source projects is frequent releases
b) R has sophisticated graphics capabilities
c) S’s base graphics system allows for very fine control over essentially every aspect of a plot or graph
d) All of the mentioned

Answer: c
Explanation: R has maintained the original S philosophy, which is that it provides a language that is both useful for interactive work, but contains a powerful programming language for developing new tools.

6. Which of the following is a base package for R language?
a) util
b) lang
c) tools
d) spatial

Answer: c
Explanation: The other packages contained in the “base” system include utils, stats, datasets, graphics, grDevices, grid, methods, parallel, compiler, splines, tcltk, stats4.

7. Which of the following is “Recommended” package in R?
a) util
b) lang
c) stats
d) spatial

Answer: d
Explanation: “Recommended” packages also include boot, class, cluster, codetools, foreign, KernSmooth, lattice, mgcv, nlme, rpart, survival, MASS, nnet, Matrix.

8. What is the output of getOption(“defaultPackages”) in R studio?
a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print

Answer: b
Explanation: There are base packages (which come with R automatically), and contributed packages. The base packages are maintained by a select group of volunteers called R Core. In addition to the base packages, there are over ten thousand additional contributed packages written by individuals all over the world.

9. Advanced users can write ___ code to manipulate R objects directly.
a) C, C++
b) C++, Java
c) Java, C
d) Java

Answer: a
Explanation: For computationally-intensive tasks, C, C++ and Fortran code can be linked and called at run time.

10. Which of the following is used for Statistical analysis in R language?
a) RStudio
b) Studio
c) Heck
d) KStudio

Answer: a
Explanation: RStudio is a web application framework for R.


R Programming Questions and Answers Part-3

1. What is the class defined in the following R code?
y<-c(FALSE,2)
a) Character
b) Numeric
c) Logical
d) Integer

Answer: b
Explanation: Numeric and FALSE is executed as 0. It is somewhat different from other programming languages. Console will give a class as Numeric. A vector can only contain objects of the same class. A list is represented as a vector but can contain objects of different classes.

2. Which one of the following is not a basic datatype?
a) Numeric
b) Character
c) Data frame
d) Integer

Answer: c
Explanation: Data frame is not the basic data type of R. Numeric, character, integer are the basic types of R. The basic data types are used many times. Data frames are used to store tabular data in R. They are an important type of object in R and are used in a variety of statistical modelling applications.

3. How do you create an integer suppose 5 in R?
a) 5L
b) 5l
c) 5i
d) 5d

Answer: a
Explanation: To create an integer L should be added to the integer. L is added to specify that it is an integer. An integer can also be created with many types. If you explicitly want an integer, you need to specify the L suffix.

4. What will be the output of the following R code?
x<- c (“a”,” b”)
as.numeric(x)
a) [1] 1 2
b) [1] TRUE TRUE
c) [1] NA NA (Warning message: NAs introduced by coercion)
d) [1] NAN

Answer: c
Explanation: Characters cannot be expressed as numeric. Therefore NA’s are printed as output. NA will specify the missing elements in the list. When nonsensical coercion takes place, you will usually get a warning from R.

5. The dimension attribute is itself an integer vector of length _______
a) 1
b) 2
c) 3
d) 4

Answer: b
Explanation: It is itself an integer vector of length 2. The dimension attribute in R is an integer vector. Real values larger in modulus than the largest integer are coerced to NA. Matrices are vectors with a dimension attribute. The dimension attribute is itself an integer vector of length 2 (number of rows, number of columns).

6. How could be the matrix constructed by using the following R code?
m <- matrix(1:6, nrow = 2, ncol = 3)
a) row-wise
b) column-wise
c) any manner
d) data insufficient

Answer: b
Explanation: If nothing is mentioned, matrix is created column-wise. If we want in row-wise then we have to specify. We have to mention “by row” to create a matrix in row wise. The filter( ) function is used to extract subsets of rows from a data frame. This function is similar to the existing subset( ) function.

7. Matrices can be created by row-binding with the help of the following function.
a) rjoin()
b) rbind()
c) rowbind()
d) rbinding()

Answer: b
Explanation: rbind() is used to create a matrix by row-binding. Row- binding is the basic function of R. R – bind is used to bind the functions in R. Matrices can be created by column-binding or row-binding with the cbind() and rbind() functions.

8. What is the function used to test objects (returns a logical operator) if they are NA?
a) is.na()
b) is.nan()
c) as.na()
d) as.nan()

Answer: a
Explanation: is.na() is the function used to test if they are NA. We can check NA ‘s at any stage of the code. Generally, We will remove the NA’s for the operations in R like mean etc.., is.na() is used to test objects if they are NA.

9. What is the function used to test objects (returns a logical operator) if they are NaN?
a) as.nan()
b) is.na()
c) as.na()
d) is.nan()

Answer: d
Explanation: is.nan() is used to test if they are NaN. We can check NAN‘s at any stage of the code. We will remove the NA’s for the operations in R. is.nan() is used to test for NaN.

10. What is the function to set column names for a matrix?
a) names()
b) colnames()
c) col.names()
d) column name cannot be set for a matrix

Answer: b
Explanation: colnames() is the function to set column names for a matrix. rownames() is the function to set row names for a matrix. But we can’t use both at a time. Column names and row names can be set separately using the colnames() and rownames() functions.

R Programming Questions and Answers Part-4

1. What is output of getOption(“defaultPackages”) in R studio?
a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print

Answer: b
Explanation: There are base packages (which come with R automatically), and contributed packages. The base packages are maintained by a select group of volunteers, called R Core. In addition to the base packages, there are over ten thousand additional contributed packages written by individuals all over the world.

2. What will be the output of the following R code?
x <- c(3, 7, NA, 4, 7)
y <- c(5, NA, 1, 2, 2)
x + y
a) Symbol
b) Missing Data
c) 5
d) 15.5

Answer: b
Explanation: Missing data are a persistent and prevalent problem in many statistical analyses, especially those associated with the social sciences. R reserves the special symbol NA to represent missing data. Ordinary arithmetic with NA value gives NA’s (addition, subtraction, etc.) and applying a function to a vector that has a NA in it will usually give a NA.

3. R language is a dialect of which of the following languages?
a) S
b) C
c) MATLAB
d) SAS

Answer: a
Explanation: The R language is a dialect of S which was designed in the 1980s. Since the early 90’s the life of the S language has gone down a rather winding path. The scoping rules for R are the main feature that makes it different from the original S language.

4. R language has superficial similarity with _________
a) C
b) Python
c) MATLAB
d) SAS

Answer: a
Explanation: The language syntax has a superficial similarity with C, but the semantics are of the FPL (functional programming language) variety with stronger affinities with Lisp and APL. There are many syntaxes in C, which are closely resembled with R.

5. What is the mode of ‘a’ in the following R code?
a <- c(1,” a”, FALSE)
a) Numeric
b) Character
c) Integer
d) Logical

Answer: b
Explanation: All three elements can be expressed as a character. Both paste() and cat() will printout text to the console by combining multiple character vectors together. The original data are formatted as character strings so we convert them to R’s Date format for easier manipulation.

6. What is the length of b?
b <- 2:7
a) 4
b) 5
c) 6
d) 0

Answer: c
Explanation: Length of b [1] 2 3 4 5 6 7 is 6. We can also create an empty list of a prespecified length with the vector() function. Data frames are represented as a special type of list where every element of the list has to have the same length.

7. What is the mode of b in the following R code?
b <- c(TRUE, TRUE, 1)
a) Numeric
b) Character
c) Integer
d) Logical

Answer: a
Explanation: All the elements in ‘b’ can be expressed in numeric. Both paste() and cat() will printout text to the console by combining multiple character vectors together. The original data are formatted as character strings so we convert them to R’s Data format for easier manipulation.

8. What are the typeof(x) and mode(x) in the following R syntax?
x<-1:3
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric

Answer: b
Explanation: Here typeof() tells about the data type. They are an important type of object in R and are used in a variety of statistical modelling applications. You can determine an object’s type with the typeof function.

9. How many atomic vector types does R have?
a) 5
b) 6
c) 8
d) 10

Answer: b
Explanation: R language has 6 atomic data types. They are logical, integer, real, complex, string (or character) and raw. There is also a class for “raw” objects, but they are not commonly used directly in data analysis.

10. What is the function to set row names for a data frame?
a) row.names()
b) colnames()
c) col.names()
d) column name cannot be set for a data frame

Answer: a
Explanation: row.names() is the function to set row names for a data frame. Data frames have a special attribute called row.names, which indicate information about each row of the data frame.

R Programming Questions and Answers Part-5

1. The most convenient way to use R is at a graphics workstation running a ________ system.
a) windowing
b) running
c) interfacing
d) matrix

Answer: a
Explanation: Most classical statistics and much of the latest methodology is available for use with R.

2. Point out the wrong statement?
a) Setting up a workstation to take full advantage of the customizable features of R is a straightforward thing
b) q() is used to quit the R program
c) R has an inbuilt help facility similar to the man facility of UNIX
d) Windows versions of R have other optional help systems also

Answer: b
Explanation: help command is used for knowing details of particular command in R.

3. Which of the following is default prompt for UNIX environment?
a) >
b) >>
c) <
d) <<

Answer: a
Explanation: When you use the R program it issues a prompt when it expects input commands.

4. Which of the following will start the R program?
a) $ R
b) > R
c) * R
d) @ R

Answer: a
Explanation: At this point R commands may be issued.

5. Point out the wrong statement?
a) Windows versions of R have other optional help system also
b) The help.search command (alternatively ??) allows searching for help in various ways
c) R is case insensitive as are most UNIX based packages, so A and a are different symbols and would refer to different variables
d) $ R is used to start the R program

Answer: c
Explanation: R is an expression language with a very simple syntax.

6. Which of the following statement is alternative to _________
?solve
a) help(solve)
b) print(solve)
c) bind(solve)
d) matrix(solve)

Answer: a
Explanation: help is used to get more information on any specific named function.

7. Elementary commands in R consist of either _______ or assignments.
a) utilstats
b) language
c) expressions
d) packages

Answer: c
Explanation: If an expression is given as a command, it is evaluated, printed (unless specifically made invisible), and the value is lost.

8. If a command is not complete at the end of a line, R will give a different prompt, by default it is ____________
a) *
b) -
c) +
d) /

Answer: c
Explanation: Comments can be put almost anywhere, starting with a hashmark (‘#’), everything to the end of the line is a comment.

9. Command lines entered at the console are limited to about ________ bytes.
a) 3000
b) 4095
c) 5000
d) 6000

Answer: b
Explanation: Elementary commands can be grouped together into one compound expression by braces (‘{’ and ‘}’).

10. _____ text editor provides more general support mechanisms via ESS for working interactively with R.
a) EAC
b) Emacs
c) Shell
d) ECAP

Answer: b
Explanation: The recall and editing capabilities under UNIX are highly customizable.


R Programming MCQ Questions and Answers Part 6 - PrepBharat

prepbharat.com

R Programming Questions and Answers Part-6

1. A single element of a character vector is referred as ________
a) Character string
b) String
c) Data strings
d) Raw data

Answer: a
Explanation: Single element of a character vector is often referred to as a character string. Dates are represented by the Date class and can be coerced from a character string using the as.Date() function. This is a common way to end up with a Date object in R.

2. R files has an extension ______
a) .R
b) .S
c) .Rp
d) .c

Answer: a
Explanation: All R files have an extension .R. R provides a mechanism for recalling and re-executing previous commands. All S programmed files will have an extension .S. But R has many functions than S.

3. If the code is stored in the external file, which of the following function is used to call them to a working directory?
a) exec()
b) source()
c) execute()
d) sourcefile()

Answer: b
Explanation: source is available in the file menu. Today R runs on almost any standard computing platform and operating system. Its open source nature. The copyright for the primary source code for R is held by the R Foundation and is published under the GNU General Public License version

4. Advanced programmers can write ______ code to manipulate R objects.
a) Python
b) Java
c) C
d) Java Script

Answer: c
Explanation: C, C++ and Fortran can be linked. There are a number of people had used something like C/C++ programming languages to manipulate the R objects.

5. In ________ Insightful purchased the S language from Lucent for $2 million.
a) 2002
b) 2003
c) 2004
d) 2005

Answer: c
Explanation: TIBCO is the current owner of the S language. In 2008, Insightful was acquired by TIBCO for $25 million. As of this writing, TIBCO is the current owner of the S language and is its exclusive developer.

6. Functionality of R is divided into a number of __________
a) Functions
b) Domains
c) Packages
d) Files

Answer: a
Explanation: CRAN hosts many add-on packages that can extend the functionality of R. Connections allow R functions to talk to all different external objects without having to write custom code for each object.

7. Dataframes can be converted into a matrix by calling the following function data ______
a) matr()
b) matrix()
c) matrixf()
d) matrixfunc()

Answer: b
Explanation: as.matrix function should be used to coerce a data frame to a matrix. It might seem that the as.matrix() function should be used to coerce a data frame to a matrix.

8. What will be the output of the following R code?
x <- (“a”, “b”)
as.logical(x)
a) a b
b) “a” “b”
c) 1 1
d) Error

Answer: d
Explanation: It is not possible to coerce, so you will get a Warning. Logical creates a logical vector of the specified length. Each element of the vector is equal to FALSE. as.logical attempts to coerce its argument to be of a logical type.

9. What will be the output of the following R code?
a <- (“a” , “b”)
mode(a)
a) Character
b) Numeric
c) Complex
d) Integer

Answer: a
Explanation: Mode of the given command is a character. There are a complementary function writeLines() that takes a character vector and writes each element of the vector one line at a time to a text file.

10. Which of the following is not an object of R?
a) calls
b) expressions
c) strings
d) names

Answer: c
Explanation: Calls, expressions and names are the three types of objects that constitute the R language. There is really only one rule about vectors in R, which is that A vector can only contain objects of the same class. R objects can have names, which is very useful for writing readable code and self-describing objects.

R Programming MCQ Questions and Answers Part 7 - PrepBharat

prepbharat.com

R Programming Questions and Answers Part-7

1. What will be the output of the following R code?
> x <- 1
> print(x)
a) 1
b) 2
c) 3
d) 5

Answer: a
Explanation: When a complete expression is entered at the prompt, it is evaluated and the result of the evaluated expression is returned.

2. Point out the wrong statement?
a) The grammar of the language determines whether an expression is complete or not
b) The <- symbol is the assignment operator in R
c) The ## character indicates a comment
d) R does not support multi-line comments or comment blocks

Answer: c
Explanation: Unlike some other languages, R does not support multi-line comments or comment blocks.

3. Which of the R following code is example of explicit printing?
a) > x <- 5
> x
b) > x <- 5
> print(x)
c) > x <- "auto"
> x
d) > x <- "auto"
> x <- "auto"

Answer: b
Explanation: Print command is used for outputting the value.

4. Files containing R scripts ends with extension ____________
a) .S
b) .R
c) .Rp
d) .SP

Answer: b
Explanation: Under many versions of UNIX and on Windows, R provides a mechanism for recalling and re-executing previous commands.

5. Point out the wrong statement?
a) : operator is used to create integer sequences
b) The numbers in the square brackets are part of the vector itself
c) There is a difference between the actual R object and the manner in which that R object is printed to the console
d) Files containing R scripts ends with extension .R

Answer: b
Explanation: They are merely part of the printed output.

6. If commands are stored in an external file, say commands.R in the working directory work, they may be executed at any time in an R session with the command ____________
a) source(“commands.R”)
b) exec(“commands.R”)
c) execute(“commands.R”)
d) exect(“command.R”)

Answer: a
Explanation: For Windows, Source is also available on the File menu.

7. _______ will divert all subsequent output from the console to an external file.
a) sink
b) div
c) exp
d) exc

Answer: a
Explanation: sink() restores it to the console once again.

8. The entities that R creates and manipulates are known as ________
a) objects
b) task
c) container
d) packages

Answer: a
Explanation: These may be variables, arrays of numbers, character strings, functions, or more general structures built from such components.

9. Which of the following can be used to display the names of (most of) the objects which are currently stored within R?
a) object()
b) objects()
c) list()
d) class()

Answer: b
Explanation: During an R session, objects are created and stored by name.

10. Collection of objects currently stored in R is called as ________________
a) package
b) workspace
c) list
d) task

Answer: b
Explanation: All objects created during an R session can be stored permanently in a file for use in future R sessions.

R Programming Questions and Answers Part-8

1. R has how many atomic classes of objects?
a) 1
b) 2
c) 3
d) 5

Answer: d
Explanation: The most basic type of R object is a vector.

2. Point out the correct statement?
a) Empty vectors can be created with the vector() function
b) A sequence is represented as a vector but can contain objects of different classes
c) “raw” objects are commonly used directly in data analysis
d) The value NaN represents undefined value

Answer: a
Explanation: A vector can only contain objects of the same class.

3. Numbers in R are generally treated as _______ precision real numbers.
a) single
b) double
c) real
d) imaginary

Answer: b
Explanation: This means that even if you see a number like “1” or “2” in R, which you might think of as integers, they are likely represented behind the scenes as numeric objects something like “1.00” or “2.00”.

4. If you explicitly want an integer, you need to specify the _____ suffix.
a) D
b) R
c) L
d) K

Answer: c
Explanation: Entering 1 in R gives you a numeric object; entering 1L explicitly gives you an integer object.

5. Point out the correct statement?
a) The value NaN represents undefined value
b) Number Inf represents infinity in R
c) NaN can also be thought of as a missing value
d) “raw” objects are commonly used directly in data analysis

Answer: b
Explanation: This allows us to represent entities like 1 / 0.

6. Attributes of an object (if any) can be accessed using the ______ function.
a) objects()
b) attrib()
c) attributes()
d) obj()

Answer: c
Explanation: Not all R objects contain attributes, in which case the attributes() function returns NULL.

7. R objects can have attributes, which are like ________ for the object.
a) metadata
b) features
c) expression
d) dimensions

Answer: a
Explanation: These metadata can be very useful in that they help to describe the object.

8. Which of the following can be considered as object attribute?
a) dimensions
b) class
c) length
d) all of the mentioned

Answer: d
Explanation: All objects in R have an Attribute list.

9. What will be the output of the following R code?
> x <- vector("numeric", length = 10)
> x
a) 10
b) 0 0 0 0 0 0 0 0 0 0
c) 01
d) 00120

Answer: b
Explanation: You can also use the vector() function to initialize vectors.

10. The ________ function can be used to create vectors of objects by concatenating things together.
a) cp()
b) c()
c) concat()
d) con()

Answer: b
Explanation: The simplest such structure is the numeric vector, which is a single entity consisting of an ordered collection of numbers.

R Programming Questions and Answers Part-9

1. Find the following type of vector?
a <- c(1,2,5.3,6,-2,4)
a) Numeric
b) Character
c) Integer
d) Logical

Answer: a
Explanation: The labels are always character irrespective of whether it is numeric or character and also Boolean etc. on the input vector. The nlevels functions will give the count of levels. Factors are created using the factor() function.

2. All columns in a matrix must have the same mode and the _________ length.
a) Different
b) Same
c) May be the same
d) May be different

Answer: b
Explanation: All columns in a matrix must have the same mode(numeric, character, etc) and also the same length. byrow=TRUE indicates that the matrix should be filled by rows. byrow=FALSE indicates that the matrix should be filled by columns (the default).

3. __________ provides optional labels with the columns and rows.
a) Disnames
b) Dimnames
c) Denmes
d) Demnesd

Answer: b
Explanation: byrow=TRUE indicates that the matrix should be filled by rows. byrow=FALSE indicates that the matrix should be filled by columns (the default). dimnames provides optional labels with the columns and rows.

4. _______ are similar to matrices but can have more than two dimensions.
a) Functions
b) Packages
c) Arrays
d) Columns

Answer: c
Explanation: Arrays are similar to matrices which can have more than two dimensions. See help(array) for details. Factors are created using the factor() function. We can Identify elements of a list using the [[]] convention.

5. Which is more general than a matrix, in that different columns can have different modes?
a) Data types
b) Data frames
c) Data sets
d) Databases

Answer: b
Explanation: A data frame is more general than a matrix, in that different columns can have different modes (numeric, character, factor, etc). This is similar to SAS and SPSS datasets. There are many ways to identify the elements of a data frame.

6. An ordered collection of objects or components are called ________
a) Data frames
b) Datasets
c) Databases
d) Lists

Answer: d
Explanation: An ordered collection of objects are called lists. A list allows you to gather a variety of (possibly unrelated) objects under one name. We can Identify elements of a list using the [[]] convention.

7. The ________ stores the nominal values as a vector of integers in the range of 1 to unique values in the nominal variable.
a) Factor
b) Matrix
c) Lists
d) Functions

Answer: a
Explanation: The factor stores the nominal values as a vector of integers in the range [1… k] (where k is the no. of unique values of the nominal variable), and an internal vector of character strings (the original values) mapped to these integers.

8. An ordered factor is used to represent an __________
a) Ordinal variable
b) Simple variable
c) Coordinal variable
d) Biordinal variable

Answer: a
Explanation: An ordered factor is used to represent an ordinal variable. R will treat factors as nominal variables and also ordered factors as ordinal variables in statistical procedures and graphical analyses.

9. On what basis of a variable, OS allocates memory and decides what can be stored in the reserved memory?
a) Data bases
b) Data sets
c) Data types
d) Lists

Answer: c
Explanation: Based on the data type of a variable, the OS allocates the memory and decides what can be stored on the reserved memory. This means that when you create a variable you reserve some space in memory.

10. The data type of the R-object becomes the data type of the ________
a) Functions
b) Packages
c) Variables
d) Lists

Answer: c
Explanation: In R, the variables are not declared as some data type. The variables are assigned with R-Objects and the data type of the R-object will become the data type of the variable. There are many types of R-objects.

R Programming Questions and Answers Part-10

1. Which of the following statement is invalid?
a) x <- c(1+0i, 2+4i)
b) x <- c(TRUE, FALSE)
c) x <- c(T, F)
d) None of the mentioned

Answer: d
Explanation: T and F are shorthand ways to specify TRUE and FALSE.

2. Point out the correct statement?
a) Use explicit TRUE and FALSE values when indicating logical values
b) rm command is used to remove objects in R
c) R operates on named data structures
d) All of the mentioned

Answer: d
Explanation: A number occurring by itself in an expression is taken as a vector of length one.

3. What will be the output of the following R code?
> x <- 6
> class(x)
a) “integer”
b) “numeric”
c) “real”
d) “imaginary”

Answer: b
Explanation: class is used to determine data type of the variable.

4. What will be the output of the following R code?
> x <- 0:6
> as.logical(x)
a) FALSE TRUE TRUE TRUE TRUE TRUE TRUE
b) “0” “1” “2” “3” “4” “5” “6”
c) 0 1 2 3 4 5 6
d) 6 5 5 3 2 1

Answer: a
Explanation: Sometimes, R can’t figure out how to coerce an object and this can result in NAs being produced.

5. Point out the correct statement?
a) The usual operator, <-, can be thought of as a syntactic shortcut to expression operation
b) Assignment can also be made using the function assignment()
c) Vectors can be used in arithmetic expressions, in which case the operations are performed element by element
d) seq() is used to delete the numbers

Answer: c
Explanation: Vectors occurring in the same expression need not all be of the same length.

6. Which of the following is invalid assignment?
a) > c(10.4, 5.6, 3.1, 6.4, 21.7) -> x
b) > assign("x", c(10.4, 5.6, 3.1, 6.4, 21.7))
c) > x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
d) None of the mentioned

Answer: d
Explanation: Assignments can also be made in the other direction, using the obvious change in the assignment operator.

7. What will be the output of the following R code?
> sqrt(-17)
a) -4.02
b) 4.02
c) NaN
d) 3.67

Answer: c
Explanation: These metadata can be very useful in that they help to describe the object.

8. Which of the following code constructs vector of length 11?
a) > v <- 3*x + y + 1
b) > v <- 3*x + y + 2
c) > v <- 2*x + y + 1
d) > v <- 2*x + y + 4

Answer: c
Explanation: The elementary arithmetic operators are the usual +, -, *, / and ^ for raising to a power.

9. _______ function returns a vector of the same size as x with the elements arranged in increasing order.
a) sort()
b) orderasc()
c) orderby()
d) sequence()

Answer: a
Explanation: There are other more flexible sorting facilities available like order() or sort.list() which produce a permutation to do the sorting.

10. Which of the following is used for generating sequences?
a) seq()
b) sequence()
c) order()
d) orderasc()

Answer: a
Explanation: R has a number of facilities for generating commonly used sequences of numbers.




Post a Comment

[facebook]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget