Function foo1
can subset (using subset()
) a list of data.frames by one or more requested variables (e.g., by = ESL == 1
or by == ESL == 1 & type == 4
).
However, I'm aware of the danger of using subset()
in R. Thus, I wonder in foo1
below, what I can use instead of subset()
to get the same output?
foo1 <- function(data, by){
s <- substitute(by)
L <- split(data, data$study.name) ; L[[1]] <- NULL
lapply(L, function(x) do.call("subset", list(x, s))) ## What to use instead of `subset`
## to get the same output?
}
# EXAMPLE OF USE:
D <- read.csv("https://raw.githubusercontent.com/izeh/i/master/k.csv", header=TRUE) # DATA
foo1(D, ESL == 1)