As it is clear from the warning message that the class of the variable "y" is "factor" and you are comparing it with "character ". You need to un-factorize a string using the as.character() function, and, then, you can compare it with character.
How to check the class of a variable:
> library(xgboost)
> library(mlbench)
> data("BreastCancer")
> y <- BreastCancer$Class
> class(y)
[1] "factor"
> y <- as.character(BreastCancer$Class)
> class(y)
[1] "character"
So, make the highlighted changes in your code and it should work.
library(xgboost)
library(mlbench)
# Wisconsin Breast Cancer Database
data("BreastCancer")
# generate data labels
y <- as.character(BreastCancer$Class)
y[y=="benign"] = 0
y[y=="malignant"] = 1
y <- as.integer(y)