I am puzzled by the scope rules that apply with sapply.

If I want to modify a vector with sapply I tried...

N <- 10
vec <- vector(mode="numeric", length=N)
test <- function(i){
  vec[i] <- i
}
sapply(1:N, test)
vec

but it not work.

How can this be done?

Worik

	[[alternative HTML version deleted]]

