Skip to content
Prev 181277 / 398502 Next

create vectors within a double loop

jim holtman:
Jim, thank you for your time. You saved my day ;-).

Just for your interest, my code (even if not elegant) works also with
"colSums()". Great function. Of course, the lapply() is probably the
elegant solution to many tasks like mine.

Kindest regards, Nikos
# loop over "classifications"
for (x in classifications) {

 # loop over sequence 1 to 10
 for (i in 1:10)

  # store sum's per "source" column
  assign ( (paste ( x, "_sums", sep = "" )[i],

    # changed from sum to colSums
    colSums ( !is.na (
    get ( paste ( x, "_thresholds", sep = "" ) ) # removed the "[ ,i]" #
   )
  )
 )
}

The 2nd question remains or it is again solved with an _apply()_
function. Maybe I'll find the answer in R_inferno?
--%<---