You are on page 1of 9

Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

reviewer4@nptel.iitm.ac.in ▼

Courses » Introduction to R Software

Announcements Course Ask a Question Progress Mentor FAQ

Unit 4 - Week
3 - Conditional executions and loops, data management
with sequences.

Course
outline
ASSIGNMENT 3
The due date for submitting this assignment has passed.
How to access As per our records you have not submitted this Due on 2018-09-05, 23:59 IST.
the portal assignment.

Week - 1 - Basic 1) If x = 23 then which one of the following is the correct outcome of y where 1 point
fundamentals, y=if ( x==23 ) { x <- x^3+3 } else { x <- x^2-3 } ?
installation and
use of software,
12164
data editing, use
of R as a 12170
calculator,
functions and 526
assignments.
123
Week 2 - Use of
No, the answer is incorrect.
R as a
calculator, Score: 0
functions and Accepted Answers:
matrix
12170
operations,
missing data 2) Which one of the following is the correct syntax to compute y for the following function? 1 point
and logical

⎧ 2x 2 + |x4 − 66|,
operators. 3
if x ≤ 0
y=⎨
⎩ x3 √ 52
Week 3 - −−

Conditional 3e − x if x > 0
executions and
loops, data
if ( x <= 0 ) { y <- 2 * x^(3/2) + abs(x^4 - 66) } else { y <- 3 *
management
with sequences. exp(x^3) - sqrt(x^(5/2))}

Lecture 12 - if ( x <= 0 ) [ y <- 2 * x^(3/2) + abs(x^4 - 66) ] else [ y <- 3 *


Basics exp(x^3) - sqrt(x^(5/2))]
calculations:
Conditional if ( x <= 0 ) { y <- 3 * exp(x^3) - sqrt(x^(5/2))} else { y <- 2 *
executions and x^(3/2) + abs(x^4 - 66)}
loops
if ( x <= 0 ) ( y <- 3 * exp(x^3) - sqrt(x^5/2)) else ( y <- 2 *
Lecture 13 - x^3/2 + abs(x^4 - 66))
Basics © 2014 NPTEL - Privacy & Terms - Honor Code - FAQs -
calculations: No, the answer is incorrect.
A project of In association with
Loops Score: 0
Lecture 14 - Accepted Answers:
Data if ( x <= 0 ) { y <- 2 * x^(3/2) + abs(x^4 - 66) } else { y <- 3 * exp(x^3) -
managment: Funded by
sqrt(x^(5/2))}
Sequences

1 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

3) Suppose xPowered
= c(12,4,16,8,20,5,14)
by then which one of the following is the correct 1 point
Lecture 15 -
Data output of
management : ifelse(x < 10, 2+x, 2*x) ?
sequences
[1] 14 8 18 16 22 10 16
Lecture 16 -
Data
[1] 14 6 18 10 22 7 16
management :
Repeats [1] 24 8 32 16 40 10 28
Lecture 17 - [1] 24 6 32 10 40 7 28
Data
management : No, the answer is incorrect.
Sorting and Score: 0
Ordering
Accepted Answers:
Quiz : [1] 24 6 32 10 40 7 28
ASSIGNMENT
3 4) Which one of the following is the correct outcome of 1 point
WEEK-3 for(i in 12:14) {print(1 - 2i + i^2)} ?
FEEDBACK

Assignment_3_Answer_keys
[1] 121
Week 4 - Data [1] 144
management [1] 169
with repeats,
sorting,
ordering, and [1] -23 + i2
lists [1] -25 + i2
[1] -27 + i2
Week 5 - Vector
indexing,
factors, Data [1] 145-2i
management
[1] 170-2i
with strings,
display and [1] 197-2i
formatting.

[1] 169
Week 6 - Data
management [1] 144
with display [1] 121
paste, split, find
and
replacement, No, the answer is incorrect.
manipulations Score: 0
with alphabets,
evaluation of Accepted Answers:
strings, data [1] 145-2i
frames. [1] 170-2i
[1] 197-2i
Week 7 - Data
frames, import 5) Which one of the following is the correct outcome of 1 point
of external data for(i in 10:14) {print(i + 2*i + 3*i**3)} ?
in various file
formats,
statistical
functions, [1] i + 2*i + 3*i**3
compilation of [1] i + 2*i + 3*i**3
data. [1] i + 2*i + 3*i**3
[1] i + 2*i + 3*i**3
Week 8 -
Graphics and
plots, statistical
functions for
[1] 3030
central
tendency, [1] 4026
variation, [1] 5220
skewness and [1] 6630

2 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

kurtosis, [1] 8274


handling of
bivarite data
through [1] 120
graphics, [1] 132
correlations,
[1] 144
programming
and illustration [1] 156
with examples. [1] 168

Error...
DOWNLOAD
VIDEOS
No, the answer is incorrect.
Score: 0
Accepted Answers:

[1] 3030
[1] 4026
[1] 5220
[1] 6630
[1] 8274

6) Which one of the following is the correct outcome of the following commands about while 1 point
loop?
y <- 5

while (y < 15) {


print(c("R Course","through NPTEL is helpful."))
y = y + 1
print(c("R Course","through NPTEL is not helpful."))
y = y + 3
}

[1] "R Course" "through NPTEL is not helpful."


[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."

[1] "R Course" "through NPTEL is not helpful."


[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is helpful."

[1] "R Course" "through NPTEL is helpful."


[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."

[1] "R Course" "through NPTEL is helpful."


[1] "R Course" "through NPTEL is helpful."

3 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

[1] "R Course" "through NPTEL is helpful."


[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is not helpful."

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."

7) Which one of the following is the correct outcome of the following while loop? 1 point
x <- 20
while(x < 35) {x <- x^2+10; if (x == 30) break; print(x); }

[1] 410

[1] 20

[1] 410
[1] 410

[1] 20
[1] 20
[1] 35
[1] 35

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 410

8) Which one of the following is the correct outcome of the command 1 point
abs(seq(-30,-35))?

[1] 30 31 32 33 34 35

[1] -30 -31 -32 -33 -34 -35

[1] 35 34 33 32 31 30

[1] -35 -34 -33 -32 -31 -30

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 30 31 32 33 34 35

9) Which one of the following is the correct output of the command 1 point
sqrt(abs(seq(-15,15, by = 6))) ?

[1] -3.872983 -3.000000 -1.732051 -1.732051 3-.000000 -3.872983

[1] 3.872983 3.000000 1.732051 1.732051 3.000000 3.872983

[1] 1.732051 3.000000 3.872983 1.732051 3.000000 3.872983

[1] 1.732051 3.000000 3.872983 3.872983 3.000000 1.732051

4 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 3.872983 3.000000 1.732051 1.732051 3.000000 3.872983

10)Which one of the following is the correct output of the command seq(20,-20, by = 1 point
-4)?

[1] -20 -16 -12 -8 -4 0 4 8 12 16 20

[1] -20 -16 -12 -8 -4 0

[1] 17 12 7 3 -3 -7 -12 -17

[1] 20 16 12 8 4 0 -4 -8 -12 -16 -20

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 20 16 12 8 4 0 -4 -8 -12 -16 -20

11) Which one of the following is the correct output of the command 1 point
seq(to = 200, length = 10)?

[1] -209 -208 -207 -206 -205 -204 -203 -202 -201 -200

[1] 191 192 193 194 195 196 197 198 199 200

[1] -191 -192 -193 -194 -195 -196 -197 -198 -199 -200

[1] 200 201 202 203 204 205 206 207 208 209

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 191 192 193 194 195 196 197 198 199 200

12)Which one of the following is the correct output of the command seq(to = -100, 1 point
length = 10) ?

[1] -109 -108 -107 -106 -105 -104 -103 -102 -101 -100

[1] 109 108 107 106 105 104 103 102 101 100

[1] 100 101 102 103 104 105 106 107 108 109

[1] -100 -101 -102 -103 -104 -105 -106 -107 -108 -109

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] -109 -108 -107 -106 -105 -104 -103 -102 -101 -100

13)Which one of the following is the correct output of the command 1 point
seq(to = 112, length = 11, by = 12) ?

[1] 4 16 28 40 52 64 76 88 100 112 114

[1] 114 112 100 88 76 64 52 40 28 16 4

[1] -8 4 16 28 40 52 64 76 88 100 112

[1] 112 100 88 76 64 52 40 28 16 4 -8

No, the answer is incorrect.


Score: 0

5 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

Accepted Answers:
[1] -8 4 16 28 40 52 64 76 88 100 112

14)Which one of the following is the correct output of the command 1 point
seq(from = -5, length = 5, by = -0.5) ?

[1] -5.0 -4.5 -4.0 -3.5 -3.0

[1] -5.0 -5.5 -6.0 -6.5 -7.0

[1] 3.0 3.5 4.0 4.5 5.0

[1] 7.0 6.5 6.0 5.5 5.0

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] -5.0 -5.5 -6.0 -6.5 -7.0

15)Which one of the following is the correct output of Y for the following commands 1 point
X <- c(78, 67, 15, 120, 3, 160, 20, 48, 9)
Y <- seq(along = X) ?

[1] 1 2 3 4 5 6 7 8 9

[1] 7 6 3 8 1 9 4 5 2

[1] 2 5 4 9 1 8 3 6 7

[1] 9 8 7 6 5 4 3 2 1

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 1 2 3 4 5 6 7 8 9

16)Which one of the following is the correct output of Y[X[3]] and Y[X[7]] for the 1 point
command
Y <- c(90, 17, 51, 80, 32, 60, 87)
X <- c(5, 7, 1, 4, 6, 3, 2) ?

51 and 87 respectively.

1 and 2 respectively.

17 and 90 respectively.

90 and 17 respectively.

No, the answer is incorrect.


Score: 0
Accepted Answers:
90 and 17 respectively.

17)Which one of the following is the correct command to generate a sequence of three yearly 1 point
dates 1-March-2016, 1- March-2017 and 1- March-2018?

seq(as.Date("2016-03-01"), as.Date("2018-03-01"), by = "years")

seq(as.date("2016-03-01"), as.date("2017-03-01"),
as.date("2018-03-01"),by = "years")

seq(as.Date(`2016-03-01’), as.Date(`2018-03-01’), by = `1’)

seq(As.Date("2016-03-01"), As.Date("2018-03-01"), by = "years")

No, the answer is incorrect.

6 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

Score: 0
Accepted Answers:
seq(as.Date("2016-03-01"), as.Date("2018-03-01"), by = "years")

18)Which one of the following is the correct command to generate the same dates (15 th ) 1 point
of 6 consecutive months starting from 15 March 2017?

seq(As.Date("2017-03-15"), by = "months", length = 6)

seq(as.date("2017-03-15"), by = "months", length = 6)

seq(as.Date("2017-03-15"), by = "months", length = 6)

seq(as.Date("2017-03-15") to as.Date("2017-08-15") by = "30")

No, the answer is incorrect.


Score: 0
Accepted Answers:
seq(as.Date("2017-03-15"), by = "months", length = 6)

19)Which one of the following is the correct outcome of the command letter[2:7] ? 1 point

[1] "b" "c" "d" "e" "f" "g"

[1] "B" "C" "D" "E" "F" "G"

[1] "2" "3" "4" "5" "6" "7"

Error...

No, the answer is incorrect.


Score: 0
Accepted Answers:
Error...

20)Which one of the following is the correct outcome of the command LETTERS[15:10] ? 1 point

[1] "o" "n" "m" "l" "k" "j"

[1] "O" "N" "M" "L" "K" "J"

[1] "J" "K" "L" "M" "N" "O"

[1] "j" "k" "l" "m" "n" "o"

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] "O" "N" "M" "L" "K" "J"

21)Which one of the following is the correct outcome of the command rep(5:9,3)? 1 point

[1] 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9

[1] 5 6 6 7 7 7 8 8 8 8 9 9 9 9 9

[1] 5 6 7 8 9 5 6 7 8 9 5 6 7 8 9

[1] 9 8 7 6 5 9 8 7 6 5 9 8 7 6 5

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 5 6 7 8 9 5 6 7 8 9 5 6 7 8 9

22)Which one of the following is the correct outcome of the command 1 point
rep(50:46, times=4) ?

7 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

1] 50 49 48 47 46 50 49 48 47 46 50 49 48 47 46 50 49 48 47 46

[1] 46 47 48 49 50 46 47 48 49 50 46 47 48 49 50 46 47 48 49 50

[1] 50 50 50 50 49 49 49 49 48 48 48 48 47 47 47 47 46 46 46 46

[1] 46 46 46 46 47 47 47 47 48 48 48 48 49 49 49 49 50 50 50 50

No, the answer is incorrect.


Score: 0
Accepted Answers:
1] 50 49 48 47 46 50 49 48 47 46 50 49 48 47 46 50 49 48 47 46

23)Which one of the following is the correct outcome of the command rep(35:40, 1 point
each=4) ?

[1] 35 36 37 38 39 40 35 36 37 38 39 40 35 36 37 38 39 40 35 36 37
38 39 40

[1] 35 35 35 35 36 36 36 36 37 37 37 37 38 38 38 38 39 39 39 39 40
40 40 40

[1] 40 40 40 40 39 39 39 39 38 38 38 38 37 37 37 37 36 36 36 36 35
35 35 35

[1] 40 39 38 37 36 35 40 39 38 37 36 35 40 39 38 37 36 35 40 39 38
37 36 35

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 35 35 35 35 36 36 36 36 37 37 37 37 38 38 38 38 39 39 39 39 40 40 40 40

24)Which one of the following is the correct outcome of the commands 1 point
x <- matrix(nrow=3, ncol=3, data=1:9, byrow=F)
rep(x, each=2) ?

[1] 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1

[1] 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9

[1] 9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1

[1] 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9

No, the answer is incorrect.


Score: 0
Accepted Answers:
[1] 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9

25)Which one of the following is the correct outcome of the command rep(c("CLASS1", " 1 point
CLASS2", " CLASS3"), each=3) ?

[1] "CLASS1" "CLASS1" "CLASS1" " CLASS2" " CLASS2" " CLASS2" "
CLASS3" " CLASS3" " CLASS3"

[1] "CLASS1" "CLASS2" "CLASS3" " CLASS1" " CLASS2" " CLASS3" "
CLASS1" " CLASS2" " CLASS3"

[1] CLASS 1 2 3 CLASS 1 2 3

[1] CLASS 1 1 CLASS 2 2 CLASS 3 3

No, the answer is incorrect.


Score: 0
Accepted Answers:

8 of 9 Wednesday 17 October 2018 12:10 AM


Introduction to R Software - - Unit 4 - Week 3 - ... https://onlinecourses.nptel.ac.in/noc18_cs52/uni...

[1] "CLASS1" "CLASS1" "CLASS1" " CLASS2" " CLASS2" " CLASS2" " CLASS3" "
CLASS3" " CLASS3"

Previous Page End

9 of 9 Wednesday 17 October 2018 12:10 AM

You might also like