library(learnr) library(tidyverse) library(tutorialExtras) library(gradethis) #for exercise library(moderndive) evals_ch5 <- evals %>% select(score, bty_avg, age) #conflicted::conflict_prefer_all("ISDSfunctions") 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 5.0 - 5.1 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.
Fill in the blanks of the code that creates a scatterplot of teaching score by beauty score and plots the regression line.
# Create the evals_ch5 dataset evals_ch5 <- moderndive::evals %>% select(score, bty_avg, age) # Create the scatterplot ggplot(evals_ch5, aes(x = ___, y = ___)) + geom_point() + labs(___ = "Beauty Score", ___ = "Teaching Score", title = "Relationship of teaching and beauty scores") + geom____(method = ___)
Common language: y by x
# Create the evals_ch5 dataset evals_ch5 <- moderndive::evals %>% select(score, bty_avg, age) # Create the scatterplot ggplot(evals_ch5, aes(x = bty_avg, y = score)) + geom_point() + labs(x = "Beauty Score", y = "Teaching Score", title = "Relationship of teaching and beauty scores") + geom_smooth(method = "lm")
grade_this_code()
quiz(caption = NULL, # Q1 question_wordbank("Q1) Match each of the following terms with whether they refer to the variable y or x in a data model.", choices = c("dependent variable", "outcome variable", "predictor variable", "explanatory variable", "independent variable"), wordbank = c("x","y"), answer(c("y", "y", "x","x","x"), correct = TRUE), allow_retry = TRUE), # Q2 question("Q2) What is the name of the commonly-used modeling technique that is the focus of Chapter 5? (Hint: it's two words)", type = "learnr_text", answer_fn(function(value){ if (str_remove_all(str_to_lower(value), " ") %in% c("linearregression")) { return(mark_as(TRUE))} return(mark_as(FALSE) ) }), allow_retry = TRUE), # Q3 question("Q3) Which of the following are TRUE of a linear regression model? ", answer("an explanatory variable can be numerical or categorical", correct = TRUE), answer("it can include more than one explanatory variable, x", correct = TRUE), answer("an outcome variable can be numerical or categorical"), answer("it can include more than one outcome variable, y"), allow_retry = TRUE, random_answer_order = TRUE), # Q4 question_numeric("Q4) How many variables are in the data frame evals_ch5?", answer(3, correct = TRUE), allow_retry = TRUE), # Q5 question_wordbank("Q5) Match the following functions with their primary purpose.", choices = c("fit a linear regression model", "identify columns of a dataframe to keep", "identify rows of a dataframe to keep", "view summary information for each variable", "look at raw data"), wordbank = c("View()", "filter()", "lm()", "select()", "skim()"), answer(c("lm()", "select()", "filter()", "skim()", "View()"), correct = TRUE), allow_retry = TRUE), # Q6 question_numeric("Q6) What is the maximum value of bty_avg in the data frame evals? Round to two decimal places.", answer(8.17, correct = TRUE), step = 0.01, allow_retry = TRUE), # Q7 question_wordbank("Q7) What is the primary purpose of the gapminder package?", choices = c("importing data files such as .csv", "data visualization", "includes datasets for analysis", "data wrangling", "computing summary statistics", "converting data to tidy format"), wordbank = c("readr", "ggplot2", "gapminder", "dplyr", "skimr", "tidyr"), answer(c("readr", "ggplot2", "gapminder", "dplyr", "skimr", "tidyr"), correct = TRUE), allow_retry = TRUE), # Q8 question("Q8) Which of the following can you conclude from the fact that the correlation coefficient between score and bty_avg is 0.187? Select all that apply.", answer("For every one unit increase in bty_avg , score increases by 0.187 on average."), answer("The slope of the best fit line for score vs. bty_avg is positive.", correct = TRUE), answer("As a bty_avg decreases, score also tends to decrease.", correct = TRUE), answer("There is a strong positive linear relationship between score and bty_avg."), allow_retry = TRUE, random_answer_order = TRUE), # Q9 question_numeric("Q9) Provide the slope of the regression line for score ~ bty_avg. Round to 3 decimal places.", answer(0.067, correct = TRUE), step = 0.001, allow_retry = TRUE), # Q10 question_numeric("Q10) What is the fitted/predicted value for the 24th instructor in the evals_ch5 dataset when fitting the regression model score ~ bty_avg?", answer(4.25, correct = TRUE), step = 0.01, allow_retry = 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.