I have a data that has 3 columns (city, score, number_of_students who get this score):
city score number_of_students
NYC 83 3000
NYC 94 220005
NYC 76 203
...
Chicago 92 450113
Chicago 64 302
Chicago 98 47
Chicago 79 500021
...
Note that there are only two cities (NYC and Chicago)
How can I parse this file in R to make it look like this:
City Score
NYC 83
NYC 83
... (3000 rows with 'NYC 83')
NYC 94
NYC 94
...(76 rows with 'NYC 94')
same for Chicago.
So I want in my new data table, every row is one student, and there are two columns: "city" shows whether this student is from NYC or Chicago; "Score" shows the score of this student.
How can I do this in R?