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 – Vectorized Operations-2

Posted on July 12, 2015 by Manish

This set of R Programming Interview Questions and Answers for experienced focuses on “Vectorized Operations”

1. Which of the following function gives the day of the week ?
a) weekdays
b) months
c) quarters
d) all of the mentioned
View Answer

Answer: a
Explanation: months function give the month name.

2. Point out the correct statement :
a) Times use the POSIXct and POSIXlt class
b) Dates and times have special classes in R that allow for numerical and statistical calculations
c) Character strings can be coerced to Date/Time classes using the strptime function
d) All of the mentioned
View Answer

Answer: d
Explanation: Character strings can be coerced to Date/Time classes using the as.Date, as.POSIXlt, or as.POSIXct.

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

> p <- as.POSIXlt(x)
> names(unclass(p))
> p$wday

a) 1
b) 2
c) 3
d) NULL
View Answer

Answer: a
Explanation: The POSIXlt object contains some useful metadata.

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

> datestring <- c("January 10, 2012 10:40", "December 9, 2011 9:10")
> x <- strptime(datestring, "%B %d, %Y %H:%M")
> x

a) “2012-01-10 10:40:00 EST” “2011-12-09 09:10:00 EST”
b) “2012-01-10 10:40:00 IST” “2011-12-09 09:10:00 IST”
c) “2012-01-10 10:40:00 GMT” “2011-12-09 09:10:00 GMT”
d) All of the mentioned
View Answer

Answer: a
Explanation: strptime() takes a character vector that has dates and times and converts them into to a POSIXlt object.

5. Point out the wrong statement :
a) POSIXct is just a very large integer under the hood
b) POSIXlt stores a bunch of other useful information like the day of the week, day of the year, month, day of the month
c) There are a number of generic functions that work on dates and times to help you extract pieces of dates and/or times
d) None of the mentioned
View Answer

Answer: d
Explanation: POSIXct uses a useful class when you want to store times in something like a data frame.

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

> x <- as.Date("2012-01-01")
> y <- strptime("9 Jan 2011 11:34:21", "%d %b %Y %H:%M:%S")
> x-y

a) Time difference of 356.3095 days
b) Warning
c) NULL
d) All of the mentioned
View Answer

Answer: b
Explanation: You can use mathematical operations on dates and times.

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

> x <- as.Date("2012-03-01")
> y <- as.Date("2012-02-28")
> x-y

a) Time difference of 3 days
b) Time difference of 2 days
c) Time difference of 1 days
d) All of the mentioned
View Answer

Answer: b
Explanation: Matrix operations are also vectorized, making for nicely compact notation.

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: Date/time classes is that they keep track of all the annoying things about dates and times, like leap years, leap seconds, daylight savings, and time zones..

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

> x <- as.POSIXct("2012-10-25 01:00:00")
> y <- as.POSIXct("2012-10-25 06:00:00", tz = "GMT")
> y-x

a) Time difference of 1 hour
b) Time difference of 1 min
c) Time difference of 1 sec
d) None of the mentioned
View Answer

Answer: a
Explanation: POSIXct is just a very large integer under the hood.

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

> x <- matrix(1:4, 2, 2)
> y <- matrix(rep(10, 4), 2, 2)
> x %*% y

a)

[,1] [,2]
[1,] 40 40
[2,] 60 60

b)

[,1] [,2]
[1,] 40 40
[2,] 80 60

c)

[,1] [,2]
[1,] 40 60
[2,] 60 60

d) None of the mentioned
View Answer

Answer: a
Explanation: We can do element-by-element operations on matrices without having to loop over every element.

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 for interviews, Here is complete set of 1000+ Multiple Choice Questions and Answers.
« Prev Page - R Programming Questions and Answers – Vectorized Operations-1
» Next Page - R Programming Questions and Answers – dplyr-1
« R Programming Questions and Answers – Vectorized Operations-1
R Programming Questions and Answers – dplyr-1 »

Deep Dive @ Sanfoundry:

  1. C# Programming Examples on Files
  2. C Programming Examples on Matrix
  3. C Programming Examples on Arrays
  4. Python Programming Examples
  5. C# Programming Examples on Strings
  6. C# Programming Examples
  7. R Programming Questions and Answers
  8. Explain String Literal Operations Using Pointers in C Programming
  9. PHP Questions & Answers – Working with Dates
  10. Ruby Programming Questions and Answers
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