如果有人可以提供更好的示例,我希望有一种方法可以将argunts传递给函数的嵌套调用,我很乐意更新此问题。
List_With_Stuff <- list(
First_List = list(
Stuff_1 = c(1,2,3),
Stuff_2 = c(4,5,6),
Stuff_3 = c(7,8,9)),
Second_List = list(
Stuff_1 = c(1,2,3),
Stuff_2 = c(4,5,6),
Stuff_3 = c(7,8,9)
需要功能的某些功能
Greater_Function_Vector <- function(Matrix_Weights,Function_Vector,If_Lower_Average = FALSE,...) {
Number_Models <- length(Matrix_Weights[ ,1])
Number_Predictions <- length(Matrix_Weights[1,])
for (i in seq_len(Number_Predictions)) {
Vector_Weights <- Matrix_Weights[, i]
Value <- Function_Vector(Vector_Weights)
for (j in seq_len(Number_Models)) {
if (Value > Vector_Weights[[j]]) {
Vector_Weights[[j]] <- 0
}
if (mean(Vector_Weights) != 0) {
} else {
if (If_Lower_Average == TRUE) {
for (j in seq_len(Number_Models)) {
Vector_Weights[[j]] <- 1 / Number_Models
}
}
}
Matrix_Weights[, i] <- Vector_Weights
}
}
return(Matrix_Weights)
}
另一个需要参数的函数
Specif_Quantile <- function(x,p,...) { quantile(x,probs = p)}
最后失败
List_Quantile_25 <- lapply(List_With_Stuff ,lapply, Greater_Function_Vector,Specif_Quantile, 0.25)