R split one column into multiple

18 views Asked by At

I have a dataframe like the following:

Car MPG
Volvo 10
Tesla 12
Ford 8
Volvo 12
Tesla 11
Ford 7

Multiple occurences of Car here are replicates and I want them in separate columns so that my final dataframe looks like:

Car    MPG1   MPG2
Volvo    10     12
Tesla    12     11
Ford      8      7

I am new to R and I think there might be some inbuilt function for this but I don't know where to search for in the documentation

0

There are 0 answers