0

I have a table like this:

Area     AgeGroup     RateOfSales
London     0-18             100
London     19-64            200
London     65+              300
York       0-18             50
York       19-64            150
York       65+              250

Area       0-18    19-64     65+
London      100     200      300
York        50      150      250

I.e. pivot so each AgeGroup variable is a column.

Can anyone advise please, I am new to R and just getting to grips with the dplyr function.

Thank you!

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • 1
    Regarding the table: please **don’t** try to post pictures. Posting the table as text (or a formatted table …) is not only encouraged but *required*. Pictures are useless. – Konrad Rudolph Oct 19 '21 at 14:29
  • FYI, terminology: `dplyr` is an R *package*, not a function; it contains many functions within it, that are made available when you `library(dplyr)`. However, pivoting data is something better handled by other packages, such as `tidyr` (a close cousin of `dplyr`, using `tidyr::pivot_*` functions), `data.table`, and `reshape2`. – r2evans Oct 19 '21 at 14:30

0 Answers0