## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(webexercises) ## ----compile-webexercises, eval=FALSE----------------------------------------- # rmarkdown::draft("exercises.Rmd", "webexercises", "webexercises") ## ----eval = FALSE------------------------------------------------------------- # # create a new book # # use default includes and scripts directories (include and R) # # output_format can be bs4_book, gitbook, html_book or tufte_html_book # add_to_bookdown(bookdown_dir = "demo_bs4", # output_format = "bs4_book", # render = TRUE) # # # update an existing book with custom include and script directories # add_to_bookdown(bookdown_dir = ".", # include_dir = "www", # script_dir = "scripts", # output_format = "gitbook") ## ----results = 'asis'--------------------------------------------------------- # echo = FALSE, results = 'asis' opts <- c("install.package", "install.packages", answer = "library", "libraries") q1 <- mcq(opts) cat("What function loads a package that is already on your computer?", q1) ## ----eval = FALSE------------------------------------------------------------- # fitb(4) ## ----echo = TRUE-------------------------------------------------------------- x <- sample(2:8, 1) ## ----eval = FALSE------------------------------------------------------------- # fitb(x) ## ----eval = FALSE------------------------------------------------------------- # fitb("E", ignore_case = TRUE) ## ----eval = FALSE------------------------------------------------------------- # fitb(c("library( tidyverse )", "library( \"tidyverse\" )", "library( 'tidyverse' )"), ignore_ws = TRUE, width = "20") ## ----eval = FALSE------------------------------------------------------------- # fitb(c("A", "E", "I", "O" , "U"), ignore_case = TRUE) ## ----eval = FALSE------------------------------------------------------------- # fitb("^[a-zA-Z]{3}$", width = 3, regex = TRUE) ## ----eval = FALSE------------------------------------------------------------- # mcq(c("tidyr", "dplyr", answer = "readr", "ggplot2")) ## ----eval = FALSE------------------------------------------------------------- # torf(TRUE) # torf(FALSE) ## ----echo = TRUE-------------------------------------------------------------- opts_p <- c( "the probability that the null hypothesis is true", answer = "the probability of the observed, or more extreme, data, under the assumption that the null-hypothesis is true", "the probability of making an error in your conclusion" ) ## ----eval=FALSE--------------------------------------------------------------- # longmcq(opts_p) ## ----echo = FALSE------------------------------------------------------------- # use sample() to randomise the order opts_ci <- sample(c( answer = "if you repeated the process many times, 95% of intervals calculated in this way contain the true mean", "there is a 95% probability that the true mean lies within this range", "95% of the data fall within this range" )) ## ----results='asis', echo = FALSE--------------------------------------------- opts <- c( "the probability that the null hypothesis is true", answer = "the probability of the observed, or more extreme, data, under the assumption that the null-hypothesis is true", "the probability of making an error in your conclusion" ) cat("What is a p-value?", longmcq(opts)) ## ----echo = FALSE------------------------------------------------------------- hist(rnorm(1000)) ## ----echo = TRUE, eval = FALSE, webex.hide = "See a hint"--------------------- # ?plot ## ----echo = FALSE, results = 'asis'------------------------------------------- js <- system.file("reports/default/webex.js", package = "webexercises") cat(paste(readLines(js), collapse = "\n"))