1

I am creating an intro to R tutorial with learnr:tutorial. One thing I have is an empty R window so people can play around with it as a basic calculator. When I go back to the shinyapps page it often has the previous code in the window that I was playing with.

Is there a way in learnr to say the first time you run this app clear all the contects?

Benn Fine
  • 11
  • 3

2 Answers2

0

I'm not familiar with learnr but in shiny you can set:

session$allowReconnect(FALSE)

to make sure a fresh session is started.

Please see this:

https://shiny.rstudio.com/articles/reconnecting.html

Btw. are you aware that you can spaw R sessions in Google Colab?:

https://colab.to/r

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
0

learnr uses a couple strategies to store users' previous answers so that they can restored when they return to a tutorial. learnr calls this Tutorial Storage and the default behavior is to use the storage mechanisms provided by browsers to have the user's browser keep track of the code or questions that were last entered.

The learnr documentation describes this in the Tutorial Storage page. There you can also find the code required to set up a storage system which I've simplified into a no-op storage strategy. You can put the code below in the setup chunk of your tutorial and every time you re-load the tutorial it should re-start without restoring any previous answers.

options(tutorial.storage = list(
  save_object = function(...) { },
  get_object = function(...) NULL,
  get_objects = function(...) list(),
  remove_all_objects = function(...) { }
)

Note: this answer was derived from Is it possible to configure learnr to always forget previous attempts · Issue #607 · rstudio/learnr.

grrrck
  • 1,066
  • 6
  • 7