A user wants to pass in the value inside the lapply function but it fails to retain the value.How to fix that?

899    Asked by Uditisingh in Data Science , Asked on Nov 5, 2019
Answered by Nitin Solanki

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, ])

This issue is caused because we did not apply the result of the loop to an object. We can do that by following

result=lapply(names(RFEresults), function(x)

{

feats <- extractFeatures(RFEresults[[x]]) featurestat[which(featurestat[, 1]==x),rownames(feats)] <- feats$time.choosen featurestat

 })

Now we can access the result by using

print(result[[1]])

print(result[[2]])



Your Answer

Interviews

Parent Categories