jeudi 9 juillet 2020

How do I create an "If, Then" for organizing data? [duplicate]

I have an excel sheet that has turned into a large data dump and I need to organize the data. I was hoping to do this in R since I can edit the code to organize multiple items. In essence, I have the data extracted as shown below with each city in its own cell.

1 NYC Chicago Detroit LA Miami
2 Chicago Sacramento Seattle LA NYC
3 Detroit Miami Sacramento NYC Chicago

I need to extract it so that the numbers at the beginning of the row will be organized with the city. It should look like this:

NYC 1 2 3
Chicago 1 2 3
Detroit 1 3
LA 1 2
Miami 1 3
Sacramento 2 3
Seattle 2

What is the easiest way to do this? I was trying to do an "If, Then" statement, but that does not seem to be working and provides an error.

Aucun commentaire:

Enregistrer un commentaire