Code in R for naivebayes