Que.Which of the following is valid syntax for if else statement in R?
|
a. if() {## do something}else {## do something else} |
b. if() {## do something}elseif {## do something else} |
c. if() {## do something}else if {## do something else} |
d. if() {##& do something}else {##@ do something else} |
if() {## do something}else {## do something else}
Que.Point out the correct statement?
|
a. Blocks are evaluated until a new line is entered after the closing brace |
b. Single statements are evaluated when a new line is typed at the start of the syntactically complete statement |
c. The if/else statement conditionally evaluates two statements |
d. Break will execute a loop while a condition is true |
The if/else statement conditionally evaluates two statements
Que.Which of the following R syntax is correct for while loop?
|
a. while ( statement1 ) statement2 |
b. while ( statement1 ) else statement2 |
c. while ( statement1 ) do statement2 |
d. while ( statement2 ) doelse statement2 |
while ( statement1 ) statement2
Que.Which of the following R code generate a uniform random number?
|
a. x <- runif(1, 0, 10)if(x > 3) {y <- 10} else {y <- 0} |
b. x <- run(1, 0, 10)if(x > 3) {y <- 10} else {y <- 0} |
c. x <- random(1, 0, 10)if(x > 3) {y <- 10} else {y <- 0} |
d. x <- random(1, 0, 10)if(x > 1) {y <- 0} else {x <- 0} |
x <- runif(1, 0, 10)if(x > 3) {y <- 10} else {y <- 0}
Que.Point out the wrong statement?
|
a. for will execute a loop a fixed number of times |
b. break will execute a loop while a condition is true |
c. if and else tests a condition and acting on it |
d. break is used to break the execution of a loop |
break will execute a loop while a condition is true
Que._______ is used to break the execution of a loop.
|
a. next |
b. skip |
c. break |
d. delete |
Que.Which of the following R code generate a sequence of integers from 1 to 10?
|
a. > for(i in 1:9) {+ print(i)+ }[1] |
b. > for(i in 0:9) {+ print(i)+ }[1] |
c. > for(i in 1:10) {+ print(i)+ }[1] |
d. > for(i in 2:50) {+ print(“i”)+ }[1] |
> for(i in 1:10) {+ print(i)+ }[1]
Que.Which of the following statement can be used to explicitly control looping?
|
a. if |
b. while |
c. break |
d. for |
Que.Which of the following should be preferred for evaluation from list of alternatives?
|
a. subsett |
b. eval |
c. switch |
d. set |
Que.What will be the output of the following R code?> x <- c("a", "b", "c", "d")
> for(i in 1:4) {
+ ## Print out each element of 'x'
+ print(x[i])
+ }
|
a. [1] “a”[1] “b”[1] “c”[1] “d” |
b. [1] “c”[1] “b”[1] “a”[1] “d” |
c. [1] “d”[1] “c”[1] “b”[1] “a” |
d. Error |
[1] “a”[1] “b”[1] “c”[1] “d”