[R] a question on the use of 'solve'

Joshua Wiley jwiley.psych at gmail.com
Tue Apr 12 23:10:06 CEST 2011


Hi Laura,

Did you ?try (a truly terrible pun).  Here is a little example:

for (i in 1:10) try(print(solve(i != 5), TRUE))

notice that for i == 5, it fails, and prints the error, but the rest
output as normal.  If you need fancier stuff, look at ?tryCatch

Hope this helps,

Josh

On Tue, Apr 12, 2011 at 10:23 AM, Laura Antolini
<laura.antolini at unimib.it> wrote:
> Dear R users,
>
>
>
> I am in trouble using the function
>
>
>
> solve(matrix)
>
>
>
> in a loop.
>
>
>
> When it happens that I have a singular matrix, I get an error message saying
> so and the loop stops.
>
>
>
> My question is if there in any way to keep on going in the loop.
>
>
>
> Thank you in advance,
>
>
>
> Laura
>
>
>
>
>
>
>
> *---------------------------------------------------------*
>
> Laura Antolini, PhD
>
> Department of Clinical Medicine and Prevention
>
> University Milano-Bicocca
>
> Monza - Italy
>
> *---------------------------------------------------------*
>
>
>
>
>
>
>
>
>        [[alternative HTML version deleted]]

Please use plain text (html makes all these blank spaces)

>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list