且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过在R的每个回合中添加新的子集变量来重复子集函数

更新时间:2023-12-02 19:41:46

您可以这样做:

foo <- function(List, what, time = 1){     
  s <- substitute(what)
  s <- bquote(.(s) & weeks == time)
  h <- lapply(List, function(x) do.call("subset", list(x, s)))
 h1 <- Filter(NROW, h)      
 h2 <- lapply(List[names(h1)], function(x) subset(x, control))
 Map(rbind, h1, h2)      
}

# AND THEN:
lapply(1:3, function(i) foo(L, type == 1, time = i))