-1

在 lapply 内但在其外打印 data.frame 的值不会保留这些值。

lapply(names(RFEresults), function(x)
   {
     feats <- extractFeatures(RFEresults[[x]])
     featurestat[which(featurestat[, 1]==x),rownames(feats)] <- feats$time.choosen
     print(featurestat[1, ])
   })

print(featurestat[1, ])

lapply 不保留值吗?

4

2 回答 2

1

尝试这个:

#assign result of the lapply loop to an object
res <- lapply(names(RFEresults), function(x)
   {
     feats <- extractFeatures(RFEresults[[x]])
     featurestat[which(featurestat[, 1]==x),rownames(feats)] <- feats$time.choosen
     featurestat #return value of the function
   })

#now you have the results of each iteration in a list
#and can access them using
print(res[[1]])
print(res[[2]])
#...
于 2013-02-25T10:55:03.283 回答
0

我不知道它是否是犹太洁食,但这应该可以:

 lapply(names(RFEresults), function(x)
 {
    feats <- extractFeatures(RFEresults[[x]])
    featurestat[which(featurestat[, 1]==x),rownames(feats)] <<- feats$time.choosen
    print(featurestat[1, ])
 })
于 2013-02-25T11:04:53.267 回答