library(learnr) library(checkr) knitr::opts_chunk$set(echo = FALSE) tutorial_options(exercise.checker = checkr::check_for_learnr) source(system.file("learnr_examples/internal-examples.R", package = "checkr"))
Fill in the blanks in the following code to create a
ggplot2
command that will produce the following scatter plot with themtcars
data.
```r library(ggplot2) ggplot(mtcars, aes(x = mpg, y = hp, color = cyl)) + geom_point()
> > There are four blanks. You'll have to replace all of them with the correct contents to generate the plot. ```r library(ggplot2) ggplot(mtcars, aes(x = ____, y = ____, color = ____)) + ____()
To check the submission, we need to create a pattern that will let us look up the student's values for each of the blanks, then compare these to the correct answer. The check_blanks()
function takes, as its second argument, an expression with the blanks. Since there are multiple blanks, each has been given a name for later reference.
check_exer_14(USER_CODE)
Calculate the hypothenuse length C of a right triangle whose other edges are A and B.
A <- 3 B <- 4 C <- ........(A^2 + B^2)
check_pythag(USER_CODE)
Try some different submissions.
C <- sqrt(A^2 + B^2)
C <- log(A^2 + B^2)
C <- ........(A^2 + B^2)
that is, the dots were not replacedC <- sqrt(A + B)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.