logo
  • Home
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Contact

R-Programming Multiple Choice Questions | MCQs | Quiz

R Programming Interview Questions and Answers
Pratice R Programming questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   R History
•   R Overview
•   R Basics
•   Console Input & Evaluation
•   Data Types - 1
•   Data Types - 2
•   Data Types - 3
•   Reading Datasets - 1
•   Reading Datasets - 2
•   Textual Data Formats
•   Connection Interfaces
•   Subsetting - 1
•   Subsetting - 2
•   Vectorized Operations-1
•   Vectorized Operations-2
•   Dplyr Basics - 1
•   Dplyr Basics - 2
•   Control Structures - 1
•   Control Structures - 2
•   Control Structures - 3
•   Functions - 1
•   Functions - 2
•   Dates & Times
•   Scoping Rules - 1
•   Scoping Rules - 2
•   Loop Functions - 1
•   Loop Functions - 2
•   Debugging
•   Debugging Tools
•   Simulation - 1
•   Simulation - 2
•   R Profiler - 1
•   R Profiler - 2
•   R ggplot2 - 1
•   R ggplot2 - 2
•   R ggplot2 - 3
•   Data Wrangling - 1
•   Data Wrangling - 2
•   Exploratory Data Analysis-1
•   Exploratory Data Analysis-2
•   Commands - 1
•   Commands - 2
•   Commands - 3
•   Packages - 1
•   Packages - 2
•   Packages - 3
•   Visualizing Data - 1
•   Visualizing Data - 2
•   Linear Regression
•   Predictive Analytics

Best Reference Books

R Programming Books
« Prev Page
Next Page »

R Programming Questions and Answers – Dates and Times

Posted on July 12, 2015 by Manish

This set of R Programming Language Multiple Choice Questions & Answers (MCQs) focuses on “Dates and Times”.

1. _________ is an indication that a fatal problem has occurred and execution of the function stops
a) message
b) error
c) warning
d) all of the mentioned
View Answer

Answer: b
Explanation: Errors are produced by the stop() function.

2. Point out the correct statement :
a) R has a number of ways to indicate to you that something’s not right
b) Executing any function in R may result in the condition
c) “condition” is a generic concept for indicating that something unexpected has occurred
d) All of the mentioned
View Answer

Answer: d
Explanation: ;Programmers can create their own custom conditions if they want.

3. What would be the value of following expression ?

 log(-1)

a) Warning in log(-1): NaNs produced
b) 1
c) Null
d) 0
View Answer

Answer: a
Explanation: This warning lets you know that taking the log of a negative number results in a NaN value because you can’t take the log of negative numbers.

4. Warnings are generated by the _________ function
a) warning()
b) error()
c) run()
d) none of the mentioned
View Answer

Answer: a
Explanation: warning is an indication that something is wrong but not necessarily fatal; execution of the function continues.

5. Point out the correct statement :
a) POSIX represents a portable operating system interface, primarily for UNIX systems
b) There are different levels of indication that can be used, ranging from mere notification to fatal error
c) The default input format for POSIX dates consists of the month, followed by the year and day, separated by slashes or dashes
d) None of the mentioned
View Answer

Answer: a
Explanation: Dates stored in the POSIX format are date/time values (like dates with the chron library), but also allow modification of time zones.

6. What will be the output of the following code ?

> printmessage <- function(x) {
+ if(x > 0)
+         print("x is greater than zero")
+ else
+         print("x is less than or equal to zero")
+ invisible(x)
+ }
> printmessage(1)

a) Error
b) Warning
c) Messages
d) All of the mentioned
View Answer

Answer: a
Explanation: The function seems to work fine. No errors, warnings, or messages.

7. To get the current date, the _______ function will return a Date object which can be converted to a different class if necessary.
a) Sys.Time
b) Sys.Date
c) Sys.DateTime
d) All of the mentioned
View Answer

Answer: b
Explanation: The POSIXlt class stores date/time values as a list of components (hour, min, sec, mon, etc.) making it easy to extract these parts.

8. Which of the followin code represents internal representation of a Date object ?
a) class(as.Date(“1970-01-02”))
b) unclass(as.Date(“1970-01-02”))
c) unclassint(as.Date(“1970-01-02”))
d) all of the mentioned
View Answer

Answer: b
Explanation: You can see the internal representation of a Date object by using the unclass() function.

9. What would be the output of the following code ?

> x <- as.Date("1970-01-01")
> x

a) “1970-01-01”
b) “1970-01-02”
c) “1970-02-01”
d) none of the mentioned
View Answer

Answer: a
Explanation: Dates are represented by the Date class and can be coerced from a character string using the as.Date() function.

10. What would be the output of the following code ?

> printmessage <- function(x) {
+ if(x > 0)
+         print("x is greater than zero")
+ else
+         print("x is less than or equal to zero")
+ invisible(x)
+ }
> printmessage(NA)

a) Error
b) Warning
c) Messages
d) All of the mentioned
View Answer

Answer: a
Explanation: You can’t do that test if x is a NA or NaN value.

Sanfoundry Global Education & Learning Series – R Programming Language.

Here’s the list of Best Reference Books in R Programming Language.

To practice all areas of R Programming Language, Here is complete set of 1000+ Multiple Choice Questions and Answers.
« Prev Page - R Programming Questions and Answers – Functions-2
» Next Page - R Programming Questions and Answers – Scoping Rules-1
« R Programming Questions and Answers – Functions-2
R Programming Questions and Answers – Scoping Rules-1 »

Deep Dive @ Sanfoundry:

  1. C Programming Examples
  2. C# Programming Examples on Files
  3. C# Programming Examples on Functions
  4. C# Programming Examples on Mathematics
  5. Python Programming Examples
  6. PHP Questions and Answers
  7. C# Programming Examples on Strings
  8. R Programming Questions and Answers
  9. Ruby Programming Questions and Answers
  10. C# Basic Programming Examples
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below:
LinkedIn | Facebook | Twitter | Google+

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
TOS & Privacy
Jobs
Bangalore Training
Online Training
SAN Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry