profile
viewpoint
遗忘

rstudio/shiny 3891

Easy interactive web applications with R

ropensci/plotly 1736

An interactive graphing library for R

rstudio/gt 1110

Easily generate information-rich, publication-quality tables from R

rstudio/plumber 1049

Turn your R code into a web API.

rstudio/flexdashboard 404

Easy interactive dashboards for R

rstudio/learnr 345

Interactive Tutorials with R Markdown

hafen/trelliscopejs 197

TrelliscopeJS R Package

bhaskarvk/leaflet.extras 182

Extra functionality for leaflet R package.

r-lib/later 102

Schedule an R function or formula to run after a specified period of time.

push eventrstudio/shinycoreci-apps

schloerke

commit sha 6fd3df8d47074bf05379658077b797ac0b514fd3

Add test results for gha-5222ce0-2020_07_16_09_28-3.5-Linux

view details

push time in 3 hours

push eventrstudio/shinycoreci-apps

schloerke

commit sha 649059daace47cec002d8040d756791b0d53d60a

Add test results for gha-5222ce0-2020_07_16_09_20-3.5-macOS

view details

push time in 3 hours

push eventrstudio/shinycoreci-apps

schloerke

commit sha e81643115a2870243bc2a41bd8abc7ccf7e2e9a4

Add test results for gha-5222ce0-2020_07_16_08_42-4.0-macOS

view details

push time in 3 hours

push eventrstudio/shinycoreci-apps

schloerke

commit sha b7f9e60f42b08185ad08ae5a312edec61e49ad31

Add test results for gha-5222ce0-2020_07_16_08_28-3.6-Linux

view details

push time in 3 hours

push eventrstudio/shinycoreci-apps

schloerke

commit sha 1cecbb75b82e0d5af2a7908558ed9346cc5974b9

Add test results for gha-5222ce0-2020_07_16_08_26-3.6-macOS

view details

push time in 4 hours

push eventrstudio/shinycoreci-apps

schloerke

commit sha 9a56bf09b7d15532cb9ca35710b63f17b104a03a

Add test results for gha-5222ce0-2020_07_16_08_26-4.0-Linux

view details

push time in 4 hours

pull request commentrstudio/plumber

Tidy plumber API

I really like the name shortening. The proposed names sound good!

I still like the idea of NAME() and NAME_METHOD() design that we have going here. My current belief is that users will be using usethis and plumber independently. Or at least namespacing usethis. I’d like to keep the prefix as is for now.

————

Let’s hold off on the cors implementation for now.

blairj09

comment created time in 8 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_08_28-3.6-macOS

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_08_30-4.0-Linux

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_08_31-3.6-Linux

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_08_28-4.0-Windows

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_09_16-3.5-macOS

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_09_26-3.5-Linux

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_08_28-3.6-Windows

delete time in 12 hours

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_08_09_39-3.5-Windows

delete time in 12 hours

push eventrstudio/shinycoreci-apps

Winston Chang

commit sha fc404b29ff6472e5807e6c5a963a174b9bbdaf58

Add test for JSON encoding

view details

Barret Schloerke

commit sha 89c0c13004a99758ce598af9d99d80608ee66540

delete a current folder

view details

Winston Chang

commit sha 5222ce0d6f172c86e4e79d8f5581e26bc02f5161

Merge pull request #67 from rstudio/wch-encoding Add test for JSON encoding

view details

Barret Schloerke

commit sha 737079b4e1dafd30bf53a7e69188113f6a92aa46

Merge branch 'master' into merge_master * master: Add test for JSON encoding

view details

Barret Schloerke

commit sha 02df910ae5ba17c3d760053b17a0c45503921399

run test (first) to validate there are no -current folders when checking

view details

push time in 16 hours

push eventrstudio/shinycoreci-apps

wch

commit sha f7de317d1b5db88f96fb8c71d6be23c82965b6ac

Add test results for gha-5222ce0-2020_07_15_18_25-3.5-Linux

view details

push time in 18 hours

create barnchrstudio/shinycoreci-apps

branch : gha-5222ce0-2020_07_15_18_25-3.5-Linux

created branch time in 18 hours

push eventrstudio/shinycoreci-apps

wch

commit sha 62a692517418df3ca7a0b2706e0710bebf554e90

Add test results for gha-5222ce0-2020_07_15_17_27-4.0-Linux

view details

push time in 18 hours

create barnchrstudio/shinycoreci-apps

branch : gha-5222ce0-2020_07_15_17_27-4.0-Linux

created branch time in 18 hours

push eventrstudio/shinycoreci-apps

wch

commit sha 44312a7935cf54459933b8c8ad0185bce1007a17

Add test results for gha-5222ce0-2020_07_15_17_27-4.0-macOS

view details

push time in 19 hours

create barnchrstudio/shinycoreci-apps

branch : gha-5222ce0-2020_07_15_17_27-4.0-macOS

created branch time in 19 hours

push eventrstudio/shinycoreci-apps

wch

commit sha c6ea8896c30ddb378daf98022e7e5f91a9ea66d4

Add test results for gha-5222ce0-2020_07_15_17_26-3.6-macOS

view details

push time in 19 hours

create barnchrstudio/shinycoreci-apps

branch : gha-5222ce0-2020_07_15_17_26-3.6-macOS

created branch time in 19 hours

push eventrstudio/shinycoreci-apps

wch

commit sha 3dee58ea2226fdadfffb3d95081375140a733653

Add test results for gha-5222ce0-2020_07_15_17_23-3.6-Linux

view details

push time in 19 hours

create barnchrstudio/shinycoreci-apps

branch : gha-5222ce0-2020_07_15_17_23-3.6-Linux

created branch time in 19 hours

push eventrstudio/plumber

Barret Schloerke

commit sha c38174cc222dca667b17167d94852345ca1a46ec

export as_attachment

view details

push time in 20 hours

Pull request review commentrstudio/plumber

Restructure serializers. Add `serializer_headers()`. Add `as_attachment()`

 NULL #' #' @param name The name of the serializer (character string) #' @param serializer The serializer to be added.+#' @param verbose Logical value which determines if a message should be printed when overwriting serializers #' #' @export-addSerializer <- function(name, serializer){-  if (is.null(.globals$serializers)){-    .globals$serializers <- list()-  }-  if (!is.null(.globals$serializers[[name]])){-    stop ("Already have a serializer by the name of ", name)+addSerializer <- function(name, serializer, verbose = TRUE) {+  if (!is.null(.globals$serializers[[name]])) {+    if (isTRUE(verbose)) {+      warning("Overwriting serializer: ", name)+    }   }   .globals$serializers[[name]] <- serializer } +# internal function to use directly within this file only. (performance purposes)+# Other files should use `serializer_identity()` to avoid confusion+serializer_identity_ <- function(val, req, res, errorHandler) {+  tryCatch({+    res$body <- val+    res$toResponse()+  }, error = function(err) {+    errorHandler(req, res, err)+  })+}+serializer_identity <- function(){+  serializer_identity_+}  -nullSerializer <- function(){-  function(val, req, res, errorHandler){+#' Return an attachment response+#'+#' This will set the appropriate fields in the `Content-Disposition` header value.+#' To make sure the attachement is used, be sure your serializer eventually calls `serializer_headers`+#'+#' @param value Response value to be saved+#' @param filename File name to use when saving the attachment.+#'   If no `filename` is provided, the `value` will be treated as a regular attachment+#' @return Object with class `"plumber_attachment"`+#' @examples

Thank you @blairj09

#' @export
#' @examples
schloerke

comment created time in 21 hours

pull request commentrstudio/plumber

Tidy plumber API

Have another addition (via @trestletech) from https://www.rplumber.io/articles/security.html#cross-origin-resource-sharing-cors

This one is also a similar situation to pr_cookie() in that it provides a clean / common interface.

## #* @filter cors
## cors <- function(res) {
##     res$setHeader("Access-Control-Allow-Origin", "*")
##     plumber::forward()
## }
pr_cors <- function(pr, origin = "*", name = "cors") {
  pr_filter(pr, name, function(res) {
    res$setHeader("Access-Control-Allow-Origin", origin)
    forward()
  })
}
blairj09

comment created time in a day

PR opened rstudio/plumber

Reviewers
Fix relative pkgdown links docs

Fixes #594 Fixes #595

PR task list:

  • [NA] Update NEWS
  • [NA] Add tests
  • [x] Update documentation with devtools::document()

For #595

Globally searched for )[# and only kept links that were within page. See screenshot of remaining links that point within their own article.

Screen Shot 2020-07-15 at 10 22 18 AM

All other (previously relative) links have added their article as well.


For #595

Fixed /articles as it isn't a valid location by adding a redirect from /articles /articles/. Looking at /articles/, the links work as expected. (I'm guessing it's a netlify issue under the hood as the HTML seems to be valid.)

+29 -27

0 comment

11 changed files

pr created time in a day

push eventrstudio/plumber

Barret Schloerke

commit sha 47c1431a68dd7dac52f732b434d28b43fc5cac5d

turn relative section links to (most likely) point to the appropriate article as well. Added redirect for '/articles' to '/articles/'

view details

push time in a day

create barnchrstudio/plumber

branch : fix_links

created branch time in a day

push eventrstudio/shinycoreci-apps

schloerke

commit sha f088a02d3e087d2150973f2504fecd7f0fbbee03

Add test results for gha-66a117b-2020_07_15_09_39-3.5-Linux

view details

push time in a day

push eventrstudio/shinycoreci-apps

schloerke

commit sha fd4ef276825d9c91a87621940d2da236434ae5e6

Add test results for gha-66a117b-2020_07_15_08_34-4.0-macOS

view details

push time in a day

push eventrstudio/shinycoreci-apps

schloerke

commit sha 6cd60bddef8e2356b80de21150a1f669de29c42f

Add test results for gha-66a117b-2020_07_15_08_27-4.0-Linux

view details

push time in a day

push eventrstudio/shinycoreci-apps

schloerke

commit sha 5e57bc0e169d78028d5723d6a3fb9e202f840e2c

Add test results for gha-66a117b-2020_07_15_08_28-3.6-Linux

view details

push time in a day

push eventrstudio/shinycoreci-apps

schloerke

commit sha 74add3a5d2ec8d4f43e7e02a0f6d79190423450d

Add test results for gha-66a117b-2020_07_15_08_27-3.6-macOS

view details

push time in a day

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_08_22-3.6-macOS

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_08_24-4.0-macOS

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_08_28-3.6-Linux

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_08_30-4.0-Linux

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_09_16-3.5-macOS

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_09_27-3.5-Linux

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_09_22-3.5-Windows

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_08_27-4.0-Windows

delete time in 2 days

delete branch rstudio/shinycoreci-apps

delete branch : gha-66a117b-2020_07_07_08_29-3.6-Windows

delete time in 2 days

issue openedrstudio/learnr

Exercise object version upgrade from 0 to 1 should have a `label`.

See how to add a label or not require it if submitting a v0 exercise to a v1 srvr.

Should be the only requirement for

https://github.com/rstudio/learnr/blob/659b1bbe82278fd027c745d1af41a52962c2f716/R/exercise.R#L156

cc @trestletech

created time in 2 days

Pull request review commentrstudio/learnr

External evaluator fixes

 knitr::opts_chunk$set(exercise.checker = function(...){  ```{r, context="server-start", include=FALSE} # Setup a remote evaluator.-options(tutorial.external.host = "http://localhost:8080")+options(tutorial.external.host = "http://localhost:8080") 
options(tutorial.external.host = "http://localhost:8080")
nischalshrestha

comment created time in 2 days

issue commentrstudio/plumber

Port existing `analogsea` / digital ocean code to a new `plumberDigitialOcean` R package

I like the name plumberDeployment!

... want to take a run at it, @meztez ? (My plate is starting to fill up with rstudio/learnr.)

schloerke

comment created time in 2 days

pull request commentrstudio/learnr

Question state - include `correct` flag

If we were to filter out the correct flag from data in save_object this would be entirely equivalent to what is happening now.

I believe it is different. If the flag is added in, all storage systems and event handlers will have access to it. I'm asking only for the client storage to not allow for the correct flag.

Also I believe that gradethis is storing an equivalent correct flag after marking exercises but this is buried in the feedback list.

😞 Boo. This should be changed.

I believe we could do this by removing feedback as well when using client storage. The feedback and "is correct" are not really used as all questions and exercises (that did not evaluate to errors) are re-evaluated on restore.


I would like the client storage (or any storage the student has access to) to never know if an answer was correct, only what was submitted.

I do see the benefit of knowing "is correct" when looking at logs of student submissions. This info just needs to be decoupled from the client storage.

rundel

comment created time in 2 days

Pull request review commentrstudio/learnr

External evaluator fixes

 install_knitr_hooks <- function() {         options$exercise.df_print <- options$exercise.df_print %||% knitr::opts_knit$get('rmarkdown.df_print') %||% "default"         all_chunks <- get_all_chunks(options) -        code_check_chunk <- get_knitr_chunk(paste0(options$label, "-code-check"))-        check_chunk <- get_knitr_chunk(paste0(options$label, "-check"))-        solution <- get_knitr_chunk(paste0(options$label, "-solution"))

Why are these being deleted?

nischalshrestha

comment created time in 2 days

Pull request review commentrstudio/learnr

Add event handler system

+record_event <- function(session, event, data) {+  recorder <- getOption("tutorial.event_recorder", default = NULL)+  if (!is.null(recorder)) {+    recorder(tutorial_id = read_request(session, "tutorial.tutorial_id"),+             tutorial_version = read_request(session, "tutorial.tutorial_version"),+             user_id = read_request(session, "tutorial.user_id"),+             event = event,+             data = data)+  }+  invisible(NULL)+}+++broadcast_progress_event_to_client <- function(session, event, data) {+  session$sendCustomMessage("tutorial.progress_event", list(+    event = event,+    data = data+  ))+}++broadcast_question_event_to_client <- function(session, label, answer) {+  broadcast_progress_event_to_client(session = session,+                                     event = "question_submission",+                                     data = list(label = label, answer = answer))+}++event_register_handler(

Thinking about this more, event_handlers_reset() and register_default_handlers() should be called inside initialize_tutorial(), not in tutorial(). This should be done as a shiny pre-rendered chunk.

The setup chunk cache is already being cleared here:

https://github.com/rstudio/learnr/blob/659b1bbe82278fd027c745d1af41a52962c2f716/R/initialize.R#L36-L41

wch

comment created time in 2 days

Pull request review commentrstudio/learnr

Add event handler system

+event_handlers <- new.env(parent = emptyenv())++#' Register an event handler callback+#'+#' Register an event handler on a per-tutorial basis. Handlers for an event will+#' be fired in the order that they were registered. If+#' `event_register_handler_once()` is used, the callback will execute only one+#' time.+#'+#' @param event The name of an event.+#' @param callback A function to be invoked when an event with a specified name+#'   occurs. The callback must take parameters `session`, `event`, and `data`.+#'+#' @return A function which, if invoked, will remove the callback.+#'+#' @export+event_register_handler <- function(event, callback) {+  if (!is.function(callback) ||+      !identical(names(formals(callback)), c("session", "event", "data")))+  {+    stop("`callback` must be a function that takes three arguments, `session`, `event`, and `data`.")+  }++  if (is.null(event_handlers[[event]])) {+    event_handlers[[event]] <- list()+    attr(event_handlers[[event]], "last_id") <- 0+  }++  id <- attr(event_handlers[[event]], "last_id", TRUE) + 1+  attr(event_handlers[[event]], "last_id") <- id++  # IDs have names like "0000000001", "0000000002", "0000000003", etc.+  id_str <- sprintf("%010d", id)+  event_handlers[[event]][[id_str]] <- callback++  # Use this instead of a local anonymous function, so that we don't capture+  # `callback`, and other objects in the removal function, which might keep some+  # objects from getting GC'd.+  invisible(create_event_handler_remover(event, id_str))+}++#' @name event_register_handler+#' @export+event_register_handler_once <- function(event, callback) {+  cancel_callback <- event_register_handler(+    event,+    function(session, event, data) {+      # Use on.exit() to ensure cancellation in case callback throws an error.+      on.exit(cancel_callback())+      callback(session, event, data)+    }+  )++  invisible(cancel_callback)+}++# Returns a function which removes an event handler.+create_event_handler_remover <- function(event, id) {+  function() {+    event_remove_handler(event, id)+  }+}++# Remove an event handler.+event_remove_handler <- function(event, id) {+  if (is.null(event_handlers[[event]]) ||+      is.null(event_handlers[[event]][[id]]))+  {+    return(invisible(FALSE))+  }++  event_handlers[[event]][[id]] <- NULL+  invisible(TRUE)+}+++event_trigger <- function(session, event, data = list()) {+  if (is.null(event_handlers[[event]])) {+    return(invisible())+  }++  # Handlers for this named event+  handlers <- event_handlers[[event]]++  # Invoke all the callbacks for this event.++  # NOTE: These are not wrapped in try-catch, so an error will stop all the rest+  # of the callbacks from executing.+  for (handler in handlers) {+    handler(session, event, data)+  }

Would like to add a tryCatch around this to make sure another package doesn't prevent user additions.

  for (handler in handlers) {
    tryCatch(
      {
        handler(session, event, data)
      }, 
      error = function(e) {
        traceback() # some form of traceback on the error?
      }
    )
  }
wch

comment created time in 2 days

issue openedrstudio/plumber

Port existing `analogsea` / digital ocean code to a new `plumberDigitialOcean` R package

The code on CRAN has been broken for at least 6 months. Plumber can not update as fast as analogsea might want to update.

This code was originally set up for showing how a toy example of plumber can be deployed to Digital Ocean. However, this adds extra dependencies and is out of scope for the plumber R package.

I propose that

  • plumber Digital Ocean code be ported to an external R package (plumberDigitalOcean?). It could then be used in the plumber documentation on how to host on Digital Ocean.
  • The existing plumber functions should not really exist in outside scripts, so they may be gutted to proved a single message of "Please visit USER/plumberDigitalOcean to run FUNC()".
    • Maybe paired with message remotes::install_github("USER/plumberDigitalOcean"); plumberDigitalOcean::FUNC()

I would welcome this breaking change.

created time in 2 days

push eventrstudio/plumber

Barret Schloerke

commit sha 84cafe1e317271f799e83008572fb7c31339ba47

Update existing docker files to use the next docker images

view details

push time in 2 days

push eventrstudio/learnr

Barret Schloerke

commit sha bef3d9b296d96a27b9c668493dbfad40fe23c7a3

Update polyglot.Rmd

view details

push time in 2 days

pull request commentrstudio/plumber

Tidy plumber API

Can we also add:

pr_cookie <- function(
  pr,
  key,
  name = "plumber",
  expiration = FALSE,
  http = TRUE,
  secure = FALSE
) {
  pr$registerHooks(
    sessionCookie(key = key, name = name, expiration = expiration, http = http, secure = secure)
  )
  invisible(pr)
}
blairj09

comment created time in 2 days

push eventrstudio/plumber

Barret Schloerke

commit sha 7842d0708e4031182efe836aca649d2d8e44dd4b

remove release docker file as the "R CMD check FILE --as-cran" is now done in GHA on each push.

view details

push time in 2 days

push eventrstudio/plumber

Barret Schloerke

commit sha f0566f9dc29ee74d2233d3d0e62c7149be6b4317

fix name

view details

push time in 2 days

push eventrstudio/plumber

Barret Schloerke

commit sha 4605327d865e25d1b3bc4073e343fb1173ee610a

consolidate docker files and keep at original location. Use 'PLUMBER_REF' to use the same Dockerfile.

view details

push time in 2 days

pull request commentrstudio/learnr

Question state - include `correct` flag

@rundel I would like to safe-guard against sending correct to the Browser for users to be able to inspect.

Do you mind adding:

  • A check in client_storage's save_object() to remove the correct flag from the data when object_id == "question_submission"
  • A comment when retrieving question submissions about how correct flag may not exist. And that the correct value should always be recalculated using the input value.

?

Thank you!

rundel

comment created time in 2 days

PR closed rstudio/learnr

Add Python code chunks (& other language support) using RMarkdown language engines

(This is an early PR as a place to discuss these changes, but please let me know if another format for discussing/troubleshooting a PR is better @schloerke !)

As per #213 I am working on a PR to enable Python (and eventually more language) support in learnr. As proof of concept, I was able to modify exercise.R to manually set knitr::opts_chunk$set(engine='python') and test with code permissible in syntax in R and Python, but with different evaluation:

x = 8
x <-10
print(x)

As a code chunk in a learnr lesson now returns:

False 8

Indicating that this chunk runs with the Python engine. However, I was unable to set this on a chunk-by-chunk basis. I would like to use the language tag specified in the knitr code chunk (e.g. the python in {python exercise=TRUE...}) OR a new knitr hook ({r exercise=TRUE, exercise.engine='python'...}.

I ran into issues modifying knitr-hooks.R to pass along this information. I tried to pass along the engine name to preserved_options in order to accesspython via options$engine in exercise.R, but this failed. This may be my lack of understanding of how knitr-hooks work (OR they might be inappropriate for this task and another method would be preferable).

Question: is there another strategy for passing along and accessing the engine option for a code chunk within exercise.R? I feel like I'm missing an aspect of the interaction between code chunks -> knitr -> exercise.R. Note that we definitely will want to use this variable to e.g. introduce conditional syntax/last line checking as per #213 for implementing multi-language support robustly in learnr.

I'll be able to move on to working with code checking/etc. issues once I can access the engine parameter from within exercise.R. Thank you!

+188 -10

42 comments

13 changed files

zoews

pr closed time in 2 days

pull request commentrstudio/learnr

Add Python code chunks (& other language support) using RMarkdown language engines

Closing this PR in favor of #390 and #397. (I will try to cherry-pick as much as I can from this PR in #397.)

Thank you, @zoews!! 🙌 🙌

zoews

comment created time in 2 days

issue closedrstudio/learnr

Feature Request: Enable non-R code exercises

In normal Rmd documents you can specify SQL-only chunks, based on a database connection via DBI:

```{r}
library(DBI)
mydata = dbConnect(RPostgres::Postgres(), 
               dbname = "some_database",
               host = 'localhost',
               port = 5432,
               user = 'postgres',
               password = 'mysecretpassword')
```
```{sql, connection=mydata}
CREATE TABLE table_name (
  PersonID int,
  LastName varchar(255),
  FirstName varchar(255)
);
```

However, this does not work with learnr. I would like to be able to do the same in an exercise so that students can directly submit SQL statements:

```{sql, connection=mydata, exercise = TRUE}

```

Where students then would have to enter SQL code into the exercise.

closed time in 2 days

lukaskawerau

issue commentrstudio/learnr

Feature Request: Enable non-R code exercises

@nischalshrestha has re-written how exercises are calculated in #390 (just merged to master). Thank you @zoews for getting the conversation started and showing what is possible.

Currently, no UI changes have been merged into master from #310. Working on this in #397

If you could test this locally, that would be great! If you run into any issues, please comment on #397, as I will be making followup adjustments there. Thank you!

<details> <summary><a href="https://github.com/rstudio/learnr/pull/397/files#diff-dc1f72612c6759cda193132f17e7add7">Example polyglot tutorial</a></summary>

---
title: "Multi-language exercises"
author: "Zoë Wilkinson Saldaña"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include = FALSE}
library(learnr)

# altered from https://datacarpentry.org/R-ecology-lesson/05-r-and-databases.html
if (!file.exists("portal_mammals.sqlite")) {
  download.file(url = "https://ndownloader.figshare.com/files/2292171",
                destfile = "portal_mammals.sqlite", mode = "wb")
}
mammals <- DBI::dbConnect(RSQLite::SQLite(), "portal_mammals.sqlite")
```

### Python or R?

The following two code exercises run language agnostic code.  It will finally evaluate to either 5 or 10.

```{r r-not-python, exercise=TRUE, exercise.lines = 5}
# if running in R, this should return 10
# if running in Python, this should return FALSE and 5
x = 5
x <-10
print(x)
```

```{python python-not-r, exercise=TRUE, exercise.lines = 5}
# if running in R, this should return 10
# if running in Python, this should return FALSE and 5
x = 5
x <-10
print(x)
```

### Bash

Execute exercises in bash

```{bash bash-not-r, exercise = TRUE}
echo "hello world"
date
```

### SQL

Use a SQL connection defined in a setup chunk.

```{sql sql-not-r, exercise = TRUE, connection="mammals"}
SELECT *
FROM `surveys`
LIMIT 10
```

</details>

Screen Shot 2020-07-14 at 11 24 13 AM


Closing as fixed in #390

lukaskawerau

comment created time in 2 days

PR opened rstudio/learnr

Polyglot UI

Followup to #390

Incorporating changes from https://github.com/rstudio/learnr/pull/310

PR task list:

  • [ ] Update NEWS
  • [ ] Add tests (if possible)
  • [ ] Update documentation with devtools::document()

Updates:

  • [x] Add polyglot tutorial
  • Exercise
    • [ ] Checker functions are passed the engine as a parameter
    • [ ] Disable checking on non-R functions? Only allow pre-check?
  • Ace support
    • [ ] disable or enable multiple language highlighting https://github.com/rstudio/learnr/pull/310#issuecomment-612762010
    • [ ] disable non-R language autocompletion. See https://github.com/rstudio/learnr/pull/310/commits/9b2c75debd596de030e76bff396a4b38f205d271
  • UI
    • [ ] Display engine processing the exercise. See https://github.com/rstudio/learnr/pull/310/commits/a0b990d14dce8fdf81bd5b327826a5559fb98552
+57 -0

0 comment

4 changed files

pr created time in 2 days

push eventrstudio/learnr

Barret Schloerke

commit sha eda13866cbe5cd3b0f4cd63be5f3110f18795bf1

Add polyglot tutorial

view details

push time in 2 days

create barnchrstudio/learnr

branch : polyglot_ui

created branch time in 2 days

issue closedrstudio/learnr

Pass variables between exercises

If I load data into a variable in one exercise that variable is not found in the next exercise.

closed time in 2 days

rachelss

issue commentrstudio/learnr

Pass variables between exercises

@nischalshrestha has created a fair compromise by allowing for setup chunks to be chained together. in #390 which was just merged.

  • All setup chunks must be explicitly declared. (Except for the default NAME-setup exercise setup chunk.)
  • The chain of setup chunks must not form a cycle
  • Setup chunks are allowed to point to other exercise chunks, however it will be treated like a regular Rmd chunk and not look for the default NAME-setup chunk and will use the code provided in the document. (Not the user's latest submission.)

Example:

```{r setup, include = FALSE}
library(learnr)
d <- 3
``` 

```{r setupA}
a <- 5 
``` 

```{r setupB, exercise.setup = "setupA"}
b <- a + d
``` 


Default behavior.
Chunks that will be executed: setup, user submission for ex0
```{r ex0, exercise=TRUE} 
d # 3
```

Chain setup values.
Chunks that will be executed: setup, setupA, setupB, user submission for ex1
```{r ex1, exercise=TRUE, exercise.setup = "setupB"} 
x <- b + 1
x # 9
```

Do not need to use the full chain.
Chunks that will be executed: setup, setupA, user submission for ex2
```{r ex2, exercise=TRUE, exercise.setup = "setupA"}
y <- a + 1 
y # 6
```

Use other exercise's pre-filled code chunk. 
Chunks that will be executed: setup, setupA, setupB, ex1, user submission for ex3
```{r ex3, exercise=TRUE, exercise.setup = "ex1"}
z <- x + 6 
z
```

Closing as fixed in #390

rachelss

comment created time in 2 days

issue closedrstudio/learnr

Support for other languages in exercise chunks?

Given rmarkdown and knitr support for other languages, would it be possible for learnr to support other languages in exercise chunks? It would be useful to build tutorials for other languages, and/or for pipelines that span multiple languages.

Thank you.

closed time in 2 days

andersgs

issue commentrstudio/learnr

Support for other languages in exercise chunks?

Closing in favor of https://github.com/rstudio/learnr/issues/213

(Fixed in #390)

andersgs

comment created time in 2 days

issue closedrstudio/learnr

install_github("rstudio/tutor") fails with unzip error under Windows

Yesterday, I let several people install the tutor package using devtools. All Mac and Linux users had no issues and also the installation for the majority of the Windows users went well.

However, some of the Windows users ran into the problem described below (I provided two issue instances from two different users)

> devtools::install_github("rstudio/tutor")
Downloading GitHub repo rstudio/tutor@master
from URL https://api.github.com/repos/rstudio/tutor/zipball/master
Error in utils::unzip(src, exdir = target) : 
 cannot open file 'C:/Users/mshumper/AppData/Local/Temp/RtmpeE4D2Q/devtools23e061002ad9/rstudio-tutor-1476bf6/R/ace.R': No such file or directory
> devtools::install_github("rstudio/tutor")
Downloading GitHub repo rstudio/tutor@master
from URL https://api.github.com/repos/rstudio/tutor/zipball/master
Error in utils::unzip(src, exdir = target) : 
 cannot open file 'C:/Users/rb/AppData/Local/Temp/Rtmp0IlE0s/devtools416c5fc15dec/rstudio-tutor-ee380df/R/ace.R': No such file or directory

All users installed the current R version 3.3.3 and the current RStudio version 1.0.136 yesterday prior to trying to install tutor via devtools.

Even though I am on Windows 7 Enterprise using the same build like them I was not able to reproduce the bug on my machine.

The following two links suggest that this might be a new bug in the devtools package which also occurs when trying to install other packages using install_github() http://stackoverflow.com/questions/41293748/unzip-fails-using-install-github http://r.789695.n4.nabble.com/install-problem-from-Github-or-downloaded-file-td4729304.html#a4729306

However, I also found the following GitHub issue from 2015/16 with the same issue description as mine where the package maintainer modified the package to fix the Windows installation problem: https://github.com/vanatteveldt/rsyntax/issues/1

Currently, I am stuck because I am not able to reproduce the issue myself. Any advise would be highly appreciated.

closed time in 2 days

alex23lemm

issue commentrstudio/learnr

install_github("rstudio/tutor") fails with unzip error under Windows

Closing as I don't believe this is an issue anymore

alex23lemm

comment created time in 2 days

push eventrstudio/learnr

Stéphane Guillou

commit sha 659b1bbe82278fd027c745d1af41a52962c2f716

typos, clarification, wrong hint reference... (#391) Co-authored-by: Stéphane Guillou <stephane.guillou@member.fsf.org>

view details

push time in 2 days

PR merged rstudio/learnr

typos, clarification, wrong hint reference...

I had a look at the PR requirements, but thought I might pass on them as these are minor fixes that don't necessarily need a NEWS entry, and definitely not a test. Hope that's OK.

+8 -7

5 comments

1 changed file

stragu

pr closed time in 2 days

delete branch rstudio/learnr

delete branch : fix-url

delete time in 2 days

push eventrstudio/learnr

Winston Chang

commit sha 72a81853fb1ec4f44aec606b2adaafa2fdcc4e41

Fix URL (#396) Co-authored-by: Winston Chang <winston@stdout.org>

view details

push time in 2 days

PR merged rstudio/learnr

Reviewers
Fix URL

For some reason, running devtools::build_readme() introduces hard line breaks in the README.md.

+1 -1

0 comment

1 changed file

wch

pr closed time in 2 days

issue closedrstudio/learnr

Warning when exercise gives invisible result

There's an internal function in exercise.R that is called when the exercise code produces an invisible result. I'm not sure why an invisible result is something you want to check for and why this feature is needed at all. @garrettgman

I think the warning being displayed will be unfriendly to most students. Might we either

  1. Allow it to be configured/disabled as an option.
  2. Set it to something more friendly, like: "Note: Using assignment in the last line means that no value will be printed." Of course, you also get the warning when the last line generates a side effect but no value, e.g. plot(1:10)
  3. Leave it to the code checking. If last_value is NULL, that might suggest a helpful hint depending on the context, but only the author of the tutorial can decide what that should be.
invisible_feedback <- function() {
  feedback_as_html(
    feedback_validated(
      list(
        message = "Last value being used to check answer is invisible. See `?invisible` for more information",
        type = "warning",
        correct = FALSE,
        location = "append"
      )
    )
  )
}

closed time in 2 days

dtkaplan
more