Skip to content

Instantly share code, notes, and snippets.

@skranz
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skranz/5f200040b548eef9e889 to your computer and use it in GitHub Desktop.
Save skranz/5f200040b548eef9e889 to your computer and use it in GitHub Desktop.
RTutor solution file to illustrate error in shiny -> server.r -> decodeMessage -> fromJSON
# Problemset ErrorTest
## Can replicate a shiny error
## 1. Please save this code as file "ErrorTest_sol.Rmd" in your working directory
## 2. Then install RTutor as explained below
## 3. Adapt the working directory set in the code chunk "create_ps" below to your working directory
## 4. Run manually all the lines of the code chunk "create_ps" below
#< ignore
```{r "create_ps",include=TRUE , eval=TRUE}
# install RTutor
# see https://github.com/skranz/RTutor
if (FALSE) {
if (!require(devtools))
install.packages("devtools")
source_gist("gist.github.com/skranz/fad6062e5462c9d0efe4")
install.rtutor(update.github=TRUE)
library(RTutor)
}
library(RTutor)
# please adapt to working directory in which you store this file
setwd("D:/libraries/RTutor/examples")
ps.name = "ErrorTest"; sol.file = paste0(ps.name,"_sol.Rmd")
libs = c() # character vector of all packages you load in the problem set
create.ps(sol.file=sol.file, ps.name=ps.name,libs=libs)
# facilitates error detection
set.restore.point.options(display.restore.point=TRUE)
show.ps(ps.name, user.name="Jane Doe", sample.solution=FALSE, launch.browser=TRUE,offline = TRUE)
```
#>
## Exercise 1 -- The error is thrown
I am a test that fails in
shiny -> server.R -> decodeMessage -> fromJSON
```{r }
#< task_notest
T = 10
x = 1:T
y = x+rnorm(T)
summary(lm(y~x))
#>
```
## Exercise 2
Nothing here (RTutor currently needs 2 code chunks)
```{r }
#< task
x = 5
#>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment