0

I am new to R and am working on a class assignment. When I type in:

points(density(rainwater$ph, adjust = 2), type = "l")

I get the error message:

Error in plot.xy(xy.coords(x, y), type = type, ...) : invalid plot type

But when I copy and paste the command from a PDF file, it works correctly. I have made sure what I type exactly matches the copy and pasted command. Can anyone tell me why typing in the exact command is not working but copy and pasting does?

Thanks for the help!

SabDeM
  • 7,050
  • 2
  • 25
  • 38
  • 1
    Welcome to SO. First of all you should read [here](http://stackoverflow.com/help/how-to-ask) about how to ask a good question; a good question has better changes to be solved and you to receive help. On the other hand a read of [this](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) is also good. It explains how to create a reproducible example in R. Help users to help you by providing a piece of your data a desired output and things you have tried so far. – SabDeM Sep 12 '15 at 20:12
  • 1
    Is that the entire error message? Is there anything after `invalid plot type`? Can you please also show the previous line of code – Rich Scriven Sep 12 '15 at 20:31
  • 1
    Maybe let's not mark down the first timer.. – geotheory Sep 12 '15 at 23:39

2 Answers2

1

I don't know, but I bet it is a typography problem. The type of graph is an l (the letter), not 1 (one, number; "Type one" plot does not exist). Maybe you are reading the letter l and thinking it is number one because they look so similar in some font types. So when you type Type="1" it does not work. When you copy from the pdf the letter is copied properly, so it works.

Marianela
  • 35
  • 6
0

Verify that you haven't misspelled something (e.g. brackets)

If not, that can be an encoding related issue. If that's the case create a new file and overwrite the old file. On my mac I use UTF-8 as well as in Ubuntu.

pachadotdev
  • 3,345
  • 6
  • 33
  • 60