I'm trying to draw a plot in R:

Here's my code:

```g<- function(x,y)
+ x**2+y**2-3*x+y+2
gb<- function(x) g(x,x)
x <- seq(-2,2,len=51)
y <- seq(-2,2,len=51)
gz<-outer(x,y,g)
contour(x,y,gz)
polygon(c(0,0,1),c(1,2,1))```

The above code works fine but when I try to add color to my plot using the following code:

``` g<- function(x,y)
+ x**2+y**2-3*x+y+2
gb<- function(x) g(x,x)
x <- seq(-2,2,len=51)
y <- seq(-2,2,len=51)
gz<-outer(x,y,g)
contour(x,y,gz)
polygon(c(0,0,1),c(1,2,1),
+ col="red",
+density=c(30,40))```

I get this error:

```Error: unexpected '=' in:
"polygon(c(0,0,1),c(1,2,1),
+ col="
``` May 28 37 views

## 1 answer to this question.

Fix this line:

`polygon(c(0,0,1),c(1,2,1), col="red", density=c(30,40))` answered May 28 by
• 870 points

## Error: could not find function - R Programming

Yes, Just like @Maverik said, It happens ...READ MORE

## "no applicable method" Error in r programming

This is caused by using an object-oriented ...READ MORE

## “subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

## Error:Shadow graphics device error: r error 4 (R code execution error) when trying to use plot() and ggplot()

Its working perfectly fine with R version ...READ MORE

+1 vote

## How to segment documents into phrases in text mining using R?

You can do this in R using ...READ MORE

## R programming logic

Use gsub to match the substring that we want ...READ MORE

## Is there way for achieving continuous integration with R?

You can use svunit for this purpose. ...READ MORE

## Error saying "could not find function "shinyUI"" in shiny R

Its a small spelling mistake that you've ...READ MORE