Может быть, вы можете попробовать код ниже
r <- subset(data, select = -which(as.character(unlist(data[1,]))%in% c("A","B") | as.numeric(as.character(unlist(data[2,])))>30))
такой, что
> r
X2 X3 X7
r1 D C C
r2 6 24 25
ДАННЫЕ
data <- structure(list(X1 = structure(2:1, .Names = c("r1", "r2"), .Label = c("7",
"A"), class = "factor"), X2 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("6", "D"), class = "factor"), X3 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("24", "C"), class = "factor"), X4 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("13", "A"), class = "factor"), X5 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("27", "B"), class = "factor"), X6 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("17", "A"), class = "factor"), X7 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("25", "C"), class = "factor"), X8 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("35", "C"), class = "factor"), X9 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("13", "B"), class = "factor"), X10 = structure(2:1, .Names = c("r1",
"r2"), .Label = c("27", "B"), class = "factor")), class = "data.frame", row.names = c("r1",
"r2"))
> data
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
r1 A D C A B A C C B B
r2 7 6 24 13 27 17 25 35 13 27