Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 如何在函数上循环';谁的身体在R?_Function_Loops - Fatal编程技术网

Function 如何在函数上循环';谁的身体在R?

Function 如何在函数上循环';谁的身体在R?,function,loops,Function,Loops,我有一个函数 function(data) { mod_bc <- lm(BC ~ 1 + Year, data = data) } 功能(数据){ 公元前 mod <- list() Cmpts <- c("BC", "DU", "OM", "SS") for(i in seq_along(Cmpts)) { mod[[i]] <- as.formula(paste0(Cmpts[

我有一个函数

function(data) {
  mod_bc <- lm(BC ~ 1 + Year, data = data) }
功能(数据){
公元前
mod <- list()
Cmpts <- c("BC", "DU", "OM", "SS")
for(i in seq_along(Cmpts)) {
  mod[[i]] <- as.formula(paste0(Cmpts[i],  " ~ ", "1 + Year"))
  
}
Tmpmod_lst <- list()
mod_lm_lst <- list()
for (i in seq_along(Cmpts)) {
  Tmpmod_lst[[i]] <- function(data) {
      mod_lm_lst[[i]] <- lm(mod[[i]], data = data)
       
  }
}

[[1]]
function(data) {
      i
      mod_lm_lst[[i]] <- lm(mod[[i]], data = data)
   }
<bytecode: 0x7fdac747dc78>