In R, type the expression that prints each province's share of orders as a percentage rounded to 1 dp.
In R, type the expression that prints each province's share of orders as a percentage rounded to 1 dp.
Answer
round(prop.table(table(orders$prov)) * 100, 1)
AB 16.7, BC 25.0, ON 33.3, QC 25.0. prop.table divides by the grand total; * 100 and round(…, 1) make it a percentage — % of Grand Total in a pivot.