learnr | Interactive Tutorials with R Markdown | Data Visualization library
kandi X-RAY | learnr Summary
kandi X-RAY | learnr Summary
The learnr package makes it easy to turn any R Markdown document into an interactive tutorial. Tutorials consist of content along with interactive components for checking and reinforcing understanding. Tutorials can include any or all of the following:. Tutorials automatically preserve work done within them, so if a user works on a few exercises or questions and returns to the tutorial later they can pick up right where they left off. Learn more about the learnr package and try example tutorials online at
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of learnr
learnr Key Features
learnr Examples and Code Snippets
Community Discussions
Trending Discussions on learnr
QUESTION
I would like to render multiple objects of the function quiz
of the library learnr
using a loop in one chunk. The R
is compiling the html-markdown
file without problems, but the rendering is not correct. It is rendering text and not a question as it is supposed to.
This is my reproducible code, currently not rendering correctly:
...ANSWER
Answered 2021-May-10 at 12:33I found a solution, It turns out that in one chunk it is not possible to render two or more functions quiz
.
My solution is to generate multiple question_text
in a loop, store them in a list
and then use eval
to call all the questions as arguments of quiz
. This is the solution:
QUESTION
Motivation: I want to write an interface that uses questions from the R package exams in learnr questions/quizzes. In R/exams each question is either an R/Markdown (Rmd) or R/LaTeX (Rnw) file with a certain structure specifying question, solution, and further meta-information. The questions can contain R code to make them dynamic, e.g., sampling numbers or certain text building blocks etc. Hence, the workflow is that first the questions are run through knitr::knit
or utils::Sweave
and then embedded in a suitable output format.
Problem: When I rmarkdown::run("learnr+rexams.Rmd")
a learnr tutorial that dynamically produces a question or quiz from an Rmd exercise I get the error:
Error in if (grepl(not_valid_char_regex, label)) { : argument is of length zero
The code for a simple reproducible example learnr+rexams.Rmd
is included below.
The reason for the error appears to be that learnr runs a function verify_tutorial_chunk_label()
that tries to assure the the learnr R chunk labels are well formatted. However, confusion is caused by the chunks that are run by the R/exams package, unnecessarily leading to the error above.
Workarounds: I can disable the verify_tutorial_chunk_label()
in the learnr namespace and then everything works well. Or I can use Rnw instead of Rmd exercises and then learnr does not conflict with Sweave()
. Also, when I run my code outside of a learnr tutorial it works fine.
Question: Can I do anything less invasive to make exams
cooperate with learnr
? For example, setting some appropriate knitr
options or something like that?
Example: This is the source for the minimal learnr tutorial learnr+rexams.Rmd
that replicates the problem. Note that everything is very much simplified and only works for certain R/exams exercises, here using the function exercise template that ships with R/exams.
ANSWER
Answered 2021-Apr-14 at 21:10The problem is that by the time learnr::question()
is called, knitr is no longer able to find the chunk label for the chunk where exams2learnr()
was called. You can get around this by setting the current chunk label before calling do.call(learnr_question, x)
:
QUESTION
I’m new to creating learnr tutorials and even more to creating packages, but after reading tutorials on these two topics, I can now create simple packages and simple learnr tutorials. Now that I know a bit about both topics, I would like to deploy my interactive tutorials in a basic package, but there are not many resources available. Can you show me how to do this in the simplest possible way?
...ANSWER
Answered 2021-Mar-06 at 22:42You'll need to:
- Create a package
- Use a tutorial inside that package
Check the chapter 2 of R Packages by Hadley Wickham. You'll understand how to start one by using:
QUESTION
I am creating a homework problem with learnr:tutorial. I want to give the students 3 attempts to solve the problem before moving to the next section. I have progressive: true
and allow_skip: false
But at the moment, there is unlimited try again and even with the incorrect answer, the user can continue to the next question. An example of a question is:
ANSWER
Answered 2020-Sep-19 at 19:46As pointed out in comments, the option you're looking for isn't implemented in the package.
This will perhaps be the case in up coming versions if your request is accepted.
In the mean time, if you're ready to rebuild the package, modification to fulfill the n attempts question is quite straight forward :
download learnr-master and unpack it in a directory
Open learnr.Rproj under RStudio
Open
R/quizz.R
, find shiny module :question_module_server_impl
and replace it by code below.Build / Install & Restart
You can now set number of retry in allow_retry argument:
QUESTION
I want to allow students to input their student ID at the beginning of every quiz they take. There are no correct answers as long as they input a 7 digit number. This is what I have right now but the function does not run when the defined answers are sot one single text. How can I accept all possible entries to a question?
...ANSWER
Answered 2020-Sep-15 at 05:52You could use shinyFeedback
and a server chunck to input the student's ID:
QUESTION
I'm writing a learnr::tutorial markdown for my students, and would like one of the slides to show the latest image from the webcam on Palmer Station, Antarctica:
https://www.usap.gov/videoclipsandmaps/palwebcam.cfm
However, the field doesn't register as an image - likely because it is some sort of gallery?
I cannot use the page link, the image adress, or the image to insert into:
...ANSWER
Answered 2020-Aug-19 at 15:37QUESTION
I would like to generate a pie radar / spider chart in python with 14 separate categories or "pizza slices". Something similar to this example created in excel or this example created with ggplot2.
This plt example was useful (code below), however the observations for different categories are connected with lines rather than having their own separate sections ("pizza slices"). Any ideas how to do this is python?
...ANSWER
Answered 2020-Jul-17 at 09:34In a radar chart, usually the values are one point per tick on the circular ax, connected with lines that form a zigzag pattern. A polar bar plot might be closer to the desired chart.
A polar bar plot is similar to a usual bar plot, but bent over a circle.
To get the bars and the labels nicely between the grid lines, the theta positions can be moved by half the bar width. And minor ticks can be used to get the grid lines back on their original position.
For consistency, the code below also changes some calls to plt.
to ax.
.
QUESTION
I am new to R so thank you in advance for your patience.
I would like to create a multiple choice quiz in R using the learnr package (the quiz content is not about r code). I have all of the questions, response options, and correct answers in a spreadsheet. Since my item bank has over 100 items, I will give a simpler example
...ANSWER
Answered 2020-Jul-15 at 18:39You can simply loop over the rows of your data or spreadsheet and use a function to set up the questions and save them in a list. My approach uses purrr::map
but you a simple for-loop we also do the trick. Try this:
QUESTION
I am using the learnr package and I would like to know if there is an easy way to change the caption of the submit button? Instead of "Submit Answer", I would like to change it to "Validate", for example. I could not find information in the package help.
...ANSWER
Answered 2018-Jul-10 at 15:46It is hardcoded, maybe make your own version of the function. Change this line quiz.R#L113:
QUESTION
I have created a tutorial in learnr
and I have noticed that for each code chunk that I create, I need to rerun the code from previous chunks if I wish to use the same data.
For instance, if I have something like this :
...ANSWER
Answered 2020-May-08 at 18:45This is a "feature" of learnr
such that any exercise can be done at any time without relying on previous steps.
The way around this is by setting up shared prepare
blocks:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install learnr
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page