I am currently studying about SVM classification and while using it, I came across a parameter **cost** which is needed to define while creating model. I have taken any arbitrarily cost value. I read that it can be checked by cross validation but I am not able perform it.

set.seed(1)

x<-matrix(rnorm(20*2),ncol=2)

y<-c(rep(-1,10),rep(1,10))

x[y==1,]=x[y==1,]+1

plot(x,col=(3-y))

dat<-data.frame(x=x,y=as.factor(y))

require(e1071)

svmfit=svm(y~.,data=dat,kernel=“linear”,cost=10,scale=FALSE)

Here, I have created the model with cost value of 10. I want to check with cross validation that is it best value or not.