Calculating accuracy and precision of Confusion Matrix

How do I calculate accuracy and precision of Confusion Matrix in R? Is there any library that I can use to calculate them?

The confumationMatrix() function in r, when given a matrix, will show it’s accuracy, precision and other details.