hi, I have a question about error-handling. Say I want to do a simulation 100 times, each experiment involves inverting a matrix. Occasionally the matrix is close to singularity, R gives an error message and the program stops right there. Is there any way I can prevent the error message, assign something (say a NULL) to the outcome, and move on? thanks a lot. ----------------------------------------- Ximing Wu Department of Agricultural & Resource Economics University of California, Berkeley http://are.berkeley.edu/~ximing/ ------------------------------------------
Hi, have a look at ?try. Cheers, Winfried On 24-Feb-03 ximing wu wrote:> hi, > I have a question about error-handling. Say I want to do a simulation 100 > times, each experiment involves inverting a matrix. Occasionally the matrix > is close to singularity, R gives an error message and the program stops > right there. Is there any way I can prevent the error message, assign > something (say a NULL) to the outcome, and move on? > > thanks a lot. > > > ----------------------------------------- > Ximing Wu > Department of Agricultural & Resource Economics > University of California, Berkeley > http://are.berkeley.edu/~ximing/ > ------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help--------------------------------------------------------------------- E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de> Date: 24-Feb-03 Dipl.-Math. Winfried Theis SFB 475, Fachbereich Statistik, Universit"at Dortmund, 44221 Dortmund Tel.: +49-231-755-5903 FAX: +49-231-755-4387 ----------------------------------------------------------------------
look at ?try url: www.econ.uiuc.edu Roger Koenker Dept. of Economics UCL, email rkoenker at uiuc.edu Department of Economics Drayton House, vox: 217-333-4558 University of Illinois 30 Gorden St, fax: 217-244-6678 Champaign, IL 61820 London,WC1H 0AX, UK vox: 020-7679-5838 On Mon, 24 Feb 2003, ximing wu wrote:> hi, > I have a question about error-handling. Say I want to do a simulation 100 > times, each experiment involves inverting a matrix. Occasionally the matrix > is close to singularity, R gives an error message and the program stops > right there. Is there any way I can prevent the error message, assign > something (say a NULL) to the outcome, and move on? > > thanks a lot. > > > ----------------------------------------- > Ximing Wu > Department of Agricultural & Resource Economics > University of California, Berkeley > http://are.berkeley.edu/~ximing/ > ------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >
On Mon, Feb 24, 2003 at 01:50:55AM -0800, ximing wu wrote:> hi, > I have a question about error-handling. Say I want to do a simulation 100 > times, each experiment involves inverting a matrix. Occasionally the matrix > is close to singularity, R gives an error message and the program stops > right there. Is there any way I can prevent the error message, assign > something (say a NULL) to the outcome, and move on?Almost a FAQ. help(try) Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz
You can achieve this with try(). Look at the second example (?try), which is probably most like what you want to do. Regards, Andrew C. Ward CAPE Centre Department of Chemical Engineering The University of Queensland Brisbane Qld 4072 Australia andreww at cheque.uq.edu.au On Monday, February 24, 2003 7:51 PM, ximing wu [SMTP:ximing at are.berkeley.edu] wrote:> hi, > I have a question about error-handling. Say I want to do a simulation 100 > times, each experiment involves inverting a matrix. Occasionally the matrix > is close to singularity, R gives an error message and the program stops > right there. Is there any way I can prevent the error message, assign > something (say a NULL) to the outcome, and move on? > > thanks a lot. > > > ----------------------------------------- > Ximing Wu > Department of Agricultural & Resource Economics > University of California, Berkeley > http://are.berkeley.edu/~ximing/ > ------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help