[R] overleap an iteration within a for-loop when error message produced
Nicolas Berkowitsch
nicolas.berkowitsch at unibas.ch
Fri Mar 4 11:04:57 CET 2011
Dear R-list member,
I'm using the function pmnorm() (-->library(mnormt)) within a for-loop.
Certain parameter values leads to an error message:
"(In sqrt(diag(S)) : NaNs produced, In sqrt(1/diag(V)) : NaNs
produced, In cov2cor(S) : diag(.) had 0 or NA entries; non-finite result
is doubtful)"
obviously because "NaNs" were produced.
Is it possible to tell R that it should overleap the iteration which
produce the error message?
Here is an example code (does not lead to an error message):
for (subject in 1:10) {
p[subject] = pmnorm(x = subject*c(-.3,1), varcov = diag(2))
}
Assume that the 5th iteration (subject=5) leads to the error message.
How can I tell R to continue with the 6th iteration?
Thanks a lot for you help and input,
Nicolas
____________
lic. phil. Nicolas A. J. Berkowitsch
Universität Basel
Fakultät für Psychologie
Economic Psychology
Missionsstrasse 62a
CH-4055 Basel
Tel. +41 61 267 05 75
E-Mail nicolas.berkowitsch at unibas.ch
Web http://psycho.unibas.ch/abteilungen/abteilung-details/home/abteilung/economic-psychology/
More information about the R-help
mailing list