library(learnr) library(tidyverse) library(tutorialExtras) library(gradethis) gradethis_setup() knitr::opts_chunk$set(echo = FALSE)
grade_server("grade")
question_text("Name:", answer_fn(function(value){ if(length(value) >= 1 ) { return(mark_as(TRUE)) } return(mark_as(FALSE) ) }), correct = "submitted", allow_retry = FALSE )
grade_button_ui(id = "grade")
Complete this tutorial while reading Sections 2.0 - 2.3 of the textbook. Each question allows 3 'free' attempts. After the third attempt a 10% deduction occurs per attempt.
You can click the "View Grade" button as many times as you would like to see your current grade and the number of attempts you are on. Before submitting make sure your grade is as expected.
Construct a scatterplot of eruptions
by waiting
using the faithful
dataset by filling in the blanks (the data is already preloaded in R).
ggplot(data = faithful, mapping = aes(x = ___, y = ___)) + ____
Common language: y by x
Make sure you open and close parenthesis after geom_point
ggplot(data = faithful, mapping = aes(x = waiting, y = eruptions)) + geom_point()
grade_this_code()
quiz( caption = "", question("Ex1Q1) Which of the following describes the relationship between eruptions and waiting? Check all that apply.", answer("Positive association", correct = TRUE), answer("Negative association", message = "Look at the trend going from left to right"), answer("No association", message = "Are you sure?"), answer("Linear", correct = TRUE), answer("Non-linear", message = "Check the graph again."), allow_retry = TRUE, random_answer_order = TRUE) )
#reading check 2 quiz( caption = NULL, #Q1 question("Q1) What is the name of the theoretical framework for data visualization that is the foundation of the ggplot2 package?", type = "learnr_text", answer_fn(function(value){ if (str_remove_all(tolower(value), " ") %in% c("thegrammarofgraphics", "grammarofgraphics", "layeredgrammarofgraphics", "thelayeredgrammarofgraphics")) { return(mark_as(TRUE))} return(mark_as(FALSE) ) }), allow_retry = TRUE ), #Q2 question("Q2) Which of the following are examples of aesthetic attributes of geometric objects?", answer("color", correct = TRUE), answer("point"), answer("line"), answer("shape", correct = TRUE), answer("position (e.g. x and/or y coordinates)", correct = TRUE), answer("size", correct = TRUE), allow_retry = TRUE, random_answer_order = TRUE ), # Q3 question_wordbank(paste("Q3) Drag and drop the variables to match the aesthetics they are mapped onto in Figure 2.1", htmltools::img(src="images/Figure_02_1.png", height = 400, width = 700) ), choices = c("x","size", "color", "doesn't get mapped", "y"), wordbank = c("GDP per Capita", "Population", "Continent", "Country", "Life Expectancy"), answer(c("GDP per Capita", "Population", "Continent", "Country", "Life Expectancy"), correct = TRUE), allow_retry = TRUE, random_answer_order = TRUE ), # Q4 question("Q4) In a dataframe: Rows corresponds to ____ and columns correspond to ___.", answer("variables; observations"), answer("observations; variables", correct = TRUE), answer("values", "variables"), answer("observations", "values"), allow_retry = TRUE, random_answer_order = TRUE), # Q5 question("Q5) What does the term `argument` refer to in R?", answer("output of a function"), answer("input to a function", correct = TRUE), answer("assigned name of an object"), allow_retry = TRUE, random_answer_order = TRUE), # Q6 question_numeric("Q6) How many Alaska Airlines flights are in the flights data frame?", answer(714, correct = TRUE), step = 1, allow_retry = TRUE), # Q7 question("Q7) What type of relationship exists between departure delays and arrival delays for Alaska Airlines flights from NYC in 2013?", answer("positive", correct = TRUE), answer("negative"), answer("no relationship"), allow_retry = TRUE, random_answer_order = TRUE), # Q8 question("Q8) Select the statements that are TRUE about the + sign when using ggplot()", answer("Not using the + sign to add a geometric object will result in an empty plot.", correct = TRUE), answer("The + sign adds a layer to the plot.", correct = TRUE), answer("The + sign should go at the beginning of a new line."), allow_retry = TRUE, random_answer_order = TRUE), #Q9 question("Q9) What is the name of the aesthetic argument that allows you to change the transparency of a geometric object in ggplot()?", answer("alpha", correct = TRUE), answer("color"), answer("jitter"), answer("transparency"), allow_retry = TRUE, random_answer_order = TRUE) )
Once you are finished:
grade_print_ui("grade")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.