I want to import data like this with column names:
Name mfr type calories protein fat sodium fiber carbo sugars shelf vitamins serving_Size cups
100%_Bran N C 70 4 1 130 10 5 6 3 280 25 1 0.33
100%_Natural_Bran Q C 120 3 5 15 2 8 8 3 135 0 1 -1
All-Bran K C 70 4 1 260 9 7 5 3 320 25 1 0.33
All-Bran_with_Extra_Fiber K C 50 4 0 140 14 8 0 3 330 25 1 0.5
Almond_Delight R C 110 2 2 200 1 14 8 3 -1 25 1 0.75
Apple_Cinnamon_Cheerios G C 110 2 2 180 1.5 10.5 10 1 70 25 1 0.75
Apple_Jacks K C 110 2 0 125 1 11 14 2 30 25 1 1
Basic_4 G C 130 3 2 210 2 18 8 3 100 25 1.33 0.75
Bran_Chex R C 90 2 1 200 4 15 6 1 125 25 1 0.67
The problem is that when imported, RStudio puts the Name label over the mfr column, the mfr column over the type column, and so on. I tried removing the Name label and RStudio reports an error because there are not enough column names.
How do I import this into RStudio with proper column names?
R is interpreting the first column as a row name because there is one less element in the first row, the headers, than in all the others. If you add one more name after cups, the data will import as you want.