[R] a scope problem

Rajarshi Guha rxg218 at psu.edu
Fri Jun 11 00:38:17 CEST 2004


Hi,
 I have some code that looks like:

    dftc <- df[sets$tcset,]
    pt <- numeric(nrow(dftc))
    sub <- 1:nrow(dftc)
    for (i in 1:nrow(dftc)) {
        n <- nnet( fmla, data=dftc, weights=wts, subset=sub[-i], size=4,
decay=0.01)
        pt[i] <- predict( n, dftc[ i, ], type='class' )
    }

However running this give me the error:

Error in eval(expr, envir, enclos) : Object "i" not found

I have noted this problem in some other instances. For example if I
define a function

f <- function( dat, sets ) {
  # use sets
}

I sometimes get an error similar to that above. 

Does anybody know why this would happen?

(R 1.9.0 on Fedora Core 2)
-------------------------------------------------------------------
Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------
All laws are simulations of reality.
-- John C. Lilly




More information about the R-help mailing list