I believe there is no package called confusionMatrix maybe you are referring to the confusionMatrix() function from the caret package (or it could be some other package) in which case you have to install and load that package, not the function.
install.packages("caret")
library(caret)
confusionMatrix(data, ...)