Nothing
# Create a random integer vector of length 5 x <- sample(1:100, 5) # Ask for the following index between 1:5 idx <- sample(1:5, 1) # Wrong answers wrong <- sample((1:5)[-idx], 2) # The correct answer: res <- x[idx]
Vector subsetting in R. We can access elements/values
in a vectur using vector subsetting by index. Imagine we
have the following vector x
:
print(x)
If we call x[
r idx]
, what is the resulting value?
r x[wrong[1L]]
r x[wrong[2L]]
r x[idx]
x[
r idx]
returns the r idx
th element of the vector x
which is r x[idx]
.
exname: Vector subsetting extype: schoice exsolution: 001 exshuffle: True
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.