Help: I got an error that I'm stuck at.

Hello there. I got this error while doing a tutorial on Youtube by Freecodecamp. I'm an absolute noob beginner; so, please bare with me. I've heard good things about the R community; so, I naturally turned to you.
My error pretty much is that for some reason R will not plot the data (although I'm following the video step-by-step). It's called "Error in plot.window(...) : invalid 'xlim' value." I have searched online for the fix, but the answers are meant for advanced topics, whereas this is a simple one (probably). This is the code:

plot(iris$Petal.Length, iris$Petal.Width,
  col <- "#cc0000",  # Hex code for datalab.cc red
  pch <- 19,         # Use solid circles for points
  main <- "Iris: Petal Length vs. Petal Width",
  xlab <- "Petal Length", 
  ylab <- "Petal Width")

Error in plot.window(...) : invalid 'xlim' value

Additionally, I also get other errors such as "unexpected ',' in..." It's worth noting that the video goes through this line smoothly; it happens ~25:40.

Thank you in advance; any help is appreciated.

Try changing your <- to =.

Someone else will be able to explain the difference better/more accurately/clearer than I, but in this case you're not assigning a value to a variable with a persistent location in memory (<-) but providing an argument in a function (=).

1 Like

Oh that worked. I changed the = to <- in the beginning because I was getting some other error. Thank you so much for the swift response.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.