2

Is there a way to get a filtered data frame, like this:

data[data$Measure=="Baseline",]

using a variable Name for Measure, i.e. measVarName == "Measure"?

Thanks.

phiver
  • 23,048
  • 14
  • 44
  • 56
John
  • 21
  • 1

1 Answers1

3

Double bracket notation lets you select variables using a character string stored in a variable:

measVarName <- 'Measure'
data[data[[measVarName]] == 'Baseline',]
divibisan
  • 11,659
  • 11
  • 40
  • 58