I made these questions based on the Analyzing Patient Data lesson from the R programming lessons.
Suppose you had a dataframe named df:
| A | B | C | D | E |
|---|---|---|---|---|
| 02 | 66 | 04 | 94 | 12 |
| 78 | 97 | 05 | 44 | 71 |
| 92 | 32 | 55 | 17 | 73 |
| 18 | 82 | 96 | 01 | 38 |
| 49 | 25 | 15 | 80 | 02 |
How could I ask R to return the 3rd and 5th rows of the dataframe?
df[3,5]df[c(3,5)]df(c(3,5),)df[c(3,5),]With the same dataframe as above, what would the following code produce?
max(df[2:4, c(1,4)])
Misconceptions
2:4 means rows 2, 3, and 4 (not just 2 and 4)c(1,4 is different from 1:4