How to plot the data set in two different color using plot function in R

svm
r

#1

I have created a data set for the study of classification in SVM but to make data point that it belong one class and remaining data to different class I want do this by using plot function.

x<-matrix(rnorm(20*2),ncol=2) # created x
y<-c(rep(-1,10),rep(1,10)) #y for classify in SVM
plot(x,col=“red”)
I have plotted the data but my whole data is red color I want that my first 10 belong +1 which I can show by different color and remaining one with different color I want to do this because so I can decide the kernel .


#2

@hinduja1234-as you have created the data in which y as different value you can use y value to create different color the color can also changed by values . So I will suggest you to change the value color to some thing like col=n-y where n can be any natural number.

Hope this helps!
Regards,
harry


#3

@hinduja1234 - You can try this…

x<-matrix(rnorm(20*2),ncol=2) # created x
y<-c(rep(-1,10),rep(1,10)) #y for classify in SVM
co=c(rep(2,10),rep(3,10))
plot(x,col=co)

Hope this helps…