Skip to Main Content
Graphing Data with R
book

Graphing Data with R

by John Jay Hilfiger
October 2015
Beginner to intermediate content levelBeginner to intermediate
250 pages
6h 26m
English
O'Reilly Media, Inc.
Content preview from Graphing Data with R

Appendix G. Troubleshooting: Why Doesn’t My Code Work?

Beginners at almost anything will make mistakes. Fortunately, beginners with R receive error messages when they make mistakes, indicating what needs to be changed. Unfortunately, those messages are often cryptic and seem to be written in a language that only vaguely resembles English. A little experience with R will smooth the difficulties in a short time. The following pages include some examples of easily made errors and messages that accompany them. You should know that I have made each of the following errors myself, some of them many times!

Misspelling

One of the most common mistakes is simple misspelling. R, however, apparently does not have the word “misspelling” in its vocabulary and therefore labels this problem in sundry other ways:

> attach(trees)
> plt(Girth, Height)
Error: could not find function "plt"

In this example, R suggested that we wanted to use a function that does not exist, or is hiding, but it was a simple spelling error! Retype the command with the correct spelling:

> plot(Girth, Height)

Actually, you do not need to retype the whole command. In the preceding example it is not a big deal, but sometimes you will have a long line that it would be quite tedious to repeat. In that case, there are two shortcuts:

  • Copy and paste the incorrect line to the most recent prompt (>) and fix the error before pressing Return (or Enter).

  • Press the up-arrow key; the previous line will be copied, and you can edit ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

A Course in Statistics with R

A Course in Statistics with R

Prabhanjan N. Tattar, Suresh Ramaiah, B. G. Manjunath

Publisher Resources

ISBN: 9781491922606Errata Page