The carriage function is good if you need summary statistics. If all you care about is a “percentage” matrix of confusion, you can simply use prop.tableand table. In addition, for future reference, rigorous programming questions should be published on /fooobar.com / ... and not on CrossValidated.
prop.table(table(P,T))
> prop.table(table(P,T))
T
P setosa versicolor virginica
setosa 0.11333333 0.10666667 0.11333333
versicolor 0.09333333 0.13333333 0.10666667
virginica 0.12666667 0.09333333 0.11333333
, prop.table .
prop.table(caret::confusionMatrix(P,T)$table)