title: Guide to fixing errors when solving a problem set author: Sebastian Kranz, Ulm University output: pdf_document: number_sections: yes toc: yes
Here is some advice how to proceed if you get an error when solving your interactive problem set that you don't know how to solve. Please follow the seven steps in this order if you encounter an error that you cannot solve.
The whole idea of RTutor is to provide some help in automatically checking your solution. In the symbol panel on the top you see the "Addins". Click on it and then click on "Check Problemset".
If you don't see the "Addins" menu in the symbol panel, please install the newest RStudio version from here:
https://www.rstudio.com/products/rstudio/download/
If you don't see the "Check Problemset" Addin after pressing on Addins, please install the newest RTutor version. (see point 4 below)
Sometimes you have the option to type hint() to get a hint of how to solve the exercise.
Some errors will not be detected by RTutor or the error message is not really useful. Below is a list that should help you to identify and resolve some of those errors.
Sometimes an error is due to a bug in the problem set or in RTutor which may have already been fixed in the newest versions. Proceed as follows:
(Note: You may also need to remove the .RData file from your problem set folder. For a detailed description see Section 2.5 below.)
It is generally a good idea for course instructors to create such a discussion forum, e.g. on the Moodle site of the course.
On the discussion forum you should get answers either by other students or by the teaching assistant or lecturer of the course. The nice thing is that other students who encounter similar problems can then also use these answers.
Do you get an error message looking similar to the following:
> source('~/.active-rstudio-document', echo=TRUE)
Error in source("~/.active-rstudio-document", echo = TRUE) :
~/.active-rstudio-document:36:2: unexpected ')'
35:
36: b)
It could then be that you have destroyed the header or footer line of a code chunk. Your problem sets have the format of R-Markdown files (.Rmd) which are simple text files that allow to mix formatted text with R code. Here is an example:
a) Compute in R 5*5
```{r }
5*5
```
b) Now store the value 10 in the variable x ...
A code chunk starts with a line like
```{r }
and ends with a line
```
Never change those start and end lines!
Changing these lines can happen by accident, however. E.g. you may accidentally remove the footer line of the code chunk and get something like
a) Compute in R 5*5
```{r }
5*5
b) Now store the value 10 in the variable x ...
If you then check your solution, you will get a cryptic error message as above. The best is to search for the code shown in the error message (here b)
) and check whether you messed up a code chunk above.
Note that RStudio shows code chunks with a light-grey background while text has white background. This should help you to find messed up code chunks.
If your problem set uses some data, e.g. in a csv file, always download the file directly from your browser (right click on the file)
Don't open the file in Excel and save afterwards. It is very likely that Excel changes the format of the csv file and that it cannot be correctly used afterwards in your problem set.
If you have installed a brand new R version it can unfortunately sometimes happen that some R packages are not yet available for that newest R version. When you try to install them from CRAN you get an error message like:
"packages ‘magrittr’, ‘Lahman’, ‘highflights’ are not available (for R version 3.1.0)"
I don't know a better solution than installing again a previous release of R instead of the newest version. Here is a website with earlier R releases for Windows:
http://cran.r-project.org/bin/windows/base/old/
We had one case of very cryptic RTutor errors that looked similar as follows when checking your solution:
error in eval(...): cannot find function check.assign
The error could be fixed by doing the following:
.RData
and if it exists, delete it.Background: When you close RStudio, you will typically asked a question, similar as follows: "Do you want to save your Workspace to C:/folder/.RData?". If you press yes, your current R objects in the memory will be stored in the .RData file and automatically be loaded, if you start RStudio by double clicking on a file in this folder. However, sometimes you want a fresh restart of RTutor and it can cause problems if you have reloaded a workspace that was saved, after you have already run RTutor. So you need to remove the .RData file.
Alternative solution: Change RStudio options not to load .RData files
Instead of manually deleting the .RData files, you can tell RStudio to never load (or save .RData files). For this go to the menu
Tools --> Global Options
Then disable the following option and press "Apply":
In addition, you can also set the option "Save workspace to .RData on exit" to "never", to avoid that the workspace is saved when you close RStudio.
See the screenshot for the desired option settings:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.