Skip to main content

1.12) Help (cont'd)


H. If R ever goes off on a massive job that you didn’t intend, or shows with a “+” that it’s waiting for input and you don’t know what to do, you can interrupt it by clicking on the red Stop button in the menu bar. But see what happens if you type sum(1:Inf).

You will inevitably be getting error messages from time to time. We all do – programming bugs are a fact of life. Here’s some advice:

  1. Don’t (a) panic or (b) despair.
  2. Read the error message carefully and see if you can pick up any hints about where the problem lies. You needn’t understand the whole message to get a vital clue!
  3. Check to see whether a red + has appeared on one of the previous lines. This means R was waiting for you to complete the previous command ¬– perhaps you forgot to close a bracket or a set of inverted commas. Go back to the line before the “+” appeared, see why it may have been incomplete, and try again from there.
  4. Try breaking down a command into simpler ones that will work. Type in the smallest units (e.g. functions) and check whether they give what you expect. See the exercise at the end of Session 2 below for a taste of this approach.
  5. Look for another R-user who can help spot your error. It’s amazing what a fresh pair of eyes can see!
  6. Try searching the Internet – put your error message into Google. There’s loads of help out there!