I am basic level in R. It's said better to rewrite loops by apply. But for the following problem, I've no idea how to achieve that. Can anyone help? Or recommend some similar examples?
data(iris) ## iris is a dataframe
n <- ncol( iris )
for ( i in 1: (n-1) )
{
subSet <- iris[, c(i, n)] ## extract the ith column and last column for analysis
result <- someFunction( subSet ) ## analyze on the subset
score[i] <- result$score
splitVal[i] <- result$splitVal
}