Parses exercise block into code chunks

parse_exercise_list(exercise_list)

Arguments

exercise_list

Value

list with each slot containing either type "multiple" or type "Normal" with the appropriate code chunks.

Examples

chapter_file_path <- system.file("extdata/", package="decampr") chapter_list <- get_chapters(chapter_file_path) exercise_list <- get_exercises(chapter_list[[1]]) exercise_list <- parse_exercise_list(exercise_list) #show multiple exercise example exercise_list[[4]]
#> $title #> [1] "More about aes" #> #> $introduction #> [1] "For `geom_point()`, there are lots of other aesthetics. The important thing to know is that\naesthetics are properties of the `geom`. If you need to know the aesthetics that you can \nmap to a `geom`, you can always use `help()` (such as `help(geom_point)`).\n\nI'd ask you to look at `help(geom_point)`, but the documentation is not correct on Datacamp. \nInstead, look here: [http://ggplot.yhathq.com/docs/geom_point.html](http://ggplot.yhathq.com/docs/geom_point.html)\nand look at all the aesthetic mappings. \n\nWhich of the following is *not* a mappable aesthetic to `geom_point()`?" #> #> $instructions #> [1] "\n- `x`\n- `shape`\n- `linetype`\n\n" #> #> $sct #> [1] "success_msg(\"Great! Now you know where to look for mappable aesthetics.\")\nmsg1 = \"Nope. This is a mappable aesthetic to `geom_point().`\"\nmsg3 = \"Correct. `linetype` is not mappable to `geom_point()`. Points don't have a `linetype`, do they?\"\ntest_mc(correct = 3, feedback_msgs=c(msg1, msg1, msg3))" #> #> $hint #> [1] "" #> #> $type #> [1] "Multiple" #>
#show normal exercise example exercise_list[[5]]
#> $title #> [1] "Points versus lines" #> #> $introduction #> [1] "\nThe great thing about `ggplot2` is that it's easy to swap representations. \nInstead of x-y points, we can plot the data as a line graph by swapping `geom_line()`\nfor `geom_point()`." #> #> $instructions #> [1] "\nFirst run the code to see the plot with points. Change the `geom_point()` in the following graph to `geom_line()`. What happened?\nHow did the visual presentation of the data change?\n\n" #> #> $pre_exercise #> [1] "library(dplyr)\nlibrary(gapminder)\nlibrary(ggplot2)\ngap1992 <- gapminder %>% filter(year == 1992)" #> #> $sample_code #> [1] "ggplot(gap1992, aes(x = log(gdpPercap), y = lifeExp, color=continent)) +\n geom_point() " #> #> $solution #> [1] "ggplot(gap1992, aes(x = log(gdpPercap), y = lifeExp, color=continent)) +\n geom_line() " #> #> $hint #> [1] "" #> #> $type #> [1] "Normal" #>