[R] a scope problem
Tony Plate
tplate at blackmesacapital.com
Fri Jun 11 02:40:10 CEST 2004
This looks like it probably is a scope problem with non-standard evaluation
rules for the argument subset= of nnet.
Instead of subset=sub[-i], try data=dftc[-i,] (I've not tested this since
I don't have the data objects you used.)
hope this helps,
Tony Plate
At Thursday 04:38 PM 6/10/2004, you wrote:
>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
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list