更新时间:2023-11-06 22:14:34
也许您可以尝试:
w <- structure(list(subject = c(1L, 2L, 6L, 7L, 8L, 9L, 16L), sex = structure(c(2L,
2L, 2L, 2L, 1L, 1L, 1L), .Label = c("F", "M"), class = "factor"),
response = c(19.08, 16.46, 23.6, 23.96, 22.48, 25.79, 26.66
)), .Names = c("subject", "sex", "response"), class = "data.frame", row.names = c("1",
"2", "6", "7", "8", "9", "16"))
基于@hadley的评论
Based on @hadley's comments
eval(substitute(w%>% filter(y=="M"), list(y=as.name(names(w)[2]))))