Session Ready
Exercise

Interlude: How R thinks about data (1)

It was mentioned that R stores data in data frames, which you might think of as a type of spreadsheet. Each row is a different observation (a different respondent) and each column is a different variable (the first is genhlth, the second exerany and so on).

This means you can also retrieve values from our data frame using the indices (positions) of the rows and columns you want. For example, to see the sixth variable (which happens to be weight) of the 567th respondent, use the format cdc[567, 6]. This is called the row-and-column notation. Note that indices start at 1.

Instructions
100 XP
  • Assign the height of the 1337th respondent to height_1337 using the row-and-column notation. (Use names to see what the index of height is.)
  • Assign the weight of the 111th respondent to weight_111 using the row-and-column notation.