
This Practice Test is the continuation of the Data Science Foundations with R Practice Test, which is ideal for those en route to becoming certified data scientists. With this R practice Test, one can see where they stand in their data science preparation and work toward filling their knowledge gap. In case you miss any questions, adequate explanations have been provided. We highly recommend you Login / Register to take this test.
- 10 questions in all. There is no time constraint, so take your time. You need to score at least 80% to pass
- You can retake the test at any time. We recommend you share with friends too.
#1. _____ is used to skip an iteration of a loop.
Login / Register
In loop constructs like while, repeat, and for we can use next to skip to the next iteration.
#2. What will be the output of the following code?
x <-2
switch(2, 2+2, mean(1:10), rnorm(5))
Login / Register
If the value is a number between 1 and the length of the list, then the corresponding element of list is evaluated and the result returned. Here, EXPR is a number which is 2, hence the second value is taken from the list of values, which is mean(1:10) . Th output for mean(1:10) is 5.5.
#3. Which of the following is true of R statements?
Login / Register
Statements, such as x<-1:10 or mean(y), can be separated by either a semicolon or a new line. Whenever the evaluator is presented with a syntactically complete statement, that statement is evaluated and the value returned. The result of evaluating a statement can be referred to as the value of the statement. Both semicolons and new lines can be used to separate statements.
#4. What will be the output of following code?
x <-3
switch(6, 2+2, mean(1:10), rnorm(5))
Login / Register
If a value is too large or too small, NULL is returned.
#5. What will be the output of the following code?
y <-"fruit"
switch(y, fruit ="banana", vegetable ="broccoli", "Neither")
Login / Register
If a value is a character vector, then the element of “…” with a name that exactly matches value is evaluated. Here, EXPR is y whose value is “fruit.”
#6. Which of the following is true about control statements?
Login / Register
There are two statements that can be used to explicitly control looping, break and next.
#7. What will be the output of the following code?
centre <-function(x, type){
switch(type, mean=mean(x), median=median(x), trimmed =mean(x, trim = .1))
}
x <-rcauchy(10)
centre(x, "mean")
Login / Register
A common use of switch is to branch according to the character value of one of the arguments to a function. The results will differ based on the random derivates generated from rcauchy().
#8. Which statement is correct about Dissimilarity?
Login / Register
Dissimilarity is a measure that ranges from 0 to INF [0, Infinity].
#9. Which of the following codes will not print "Neither"?
Select all that apply:
Login / Register
If there is no match, a single unnamed argument is used as a default.
#10. R has ____ basic indexing operators.
Login / Register
R has three basic indexing operators. R contains several constructs that allow access to individual elements or subsets through indexing operations.
Results
HD Quiz powered by harmonic design