~/ learn/ afm-112/ cards/ Counts, shares, margins
1 of 9

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.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/7a169c3b-9d3b-473f-a1ac-f3631435ff6c/flashcard utf-8 LF