0

I have just started to use R and I need some help to pivot the data below. I have installed dplyr and wanted to see what the best way would be to pivot the data into more columns.

Below is my data set:

   Policy No          Trades    
   <chr>              <chr>                  
 1 A000001            Joinery                
 2 A000004            Barber                 
 3 A000004            Take Away Food Supplier   
 4 A000004            Beauty Salon           
 5 A000005            Dry Cleaning           
 6 A000005            Fast Food Retailing    
 7 A000005            Take Away Food Supplier   
 8 A000005            Fish & Chip Shop          
 9 A000007            Hotel - Licensed       
10 A000008            Tea Room 

I would like the data to look like this:

  Policy No Trades           Trades2              Trades3          Trades4
  <chr>     <chr>                  
1 A000001   Joinery                     
2 A000004   Barber           Take Away            Food Supplier    Beauty Salon        
3 A000005   Dry Cleaning     Fast Food Retailing  Fish & Chip Shop Take Away Food Supplier                                        
4 A000007   Hotel - Licensed       
5 A000008   Tea Room 
AndrewGB
  • 12,571
  • 4
  • 13
  • 38

0 Answers0