-2

Lets say I have the following data frame in r:

> patientData
        patientID age diabetes    status
      1         1  25   Type 1      Poor
      2         2  34   Type 2  Improved
      3         3  28   Type 1 Excellent
      4         4  52   Type 1      Poor

How can I reference a specific row or group of rows by using the specific value/level of a particular column rather than the row index? For instance, if I wanted to set a variable x to equal all of the rows which contain a patient with Type 1 diabetes or all of the rows that contain a patient in "Improved" status, how would I do that?

DylanG1991
  • 101
  • 1
  • 3
  • 11

1 Answers1

1

Try this one:

    library(dplyr)

    patientData %>%
      filter(diabetes == "Type 1")

Next time, please provide a Minimum Reproducible Example.