I am attempting to formulate code that will subset by factor level not factor name so minimal editing is required to run the code with other data sets. The number of factor levels is always 4, yet the name of those levels may change depending on the data set.1
Specifically, the name of the SET1$Bearing factors may change. For examples "001°" may be "002°" in the next data set. Presently I use this code...
SET1Bearing1<-SET1[SET1$Bearing=="001°",]
Yet this only subsets by the name of the factor. Is there a way to subset by factor level regardless of the factor name?