Re: [R] Different output for "if else" and "ifelse" that I don't understand

2017-04-28 Thread William Dunlap via R-help
Thank you - I did mean tryCatch. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Apr 28, 2017 at 10:01 AM, Bert Gunter wrote: > Typo: last line should be > > Even better, use > p3p <- tryCatch(list(...), error=function(e) list()) > > > Cheers, > > Bert > > > Bert

Re: [R] Different output for "if else" and "ifelse" that I don't understand

2017-04-28 Thread Bert Gunter
Typo: last line should be Even better, use p3p <- tryCatch(list(...), error=function(e) list()) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

Re: [R] Different output for "if else" and "ifelse" that I don't understand

2017-04-28 Thread William Dunlap via R-help
ifelse's vectorization messes this up. You could replace your original if (class(try(list(...), silent=TRUE))=="try-error") p3p <- list() else p3p <- list(...) with p3p <- if (class(try(list(...), silent=TRUE))=="try-error") list() else list(...) instead of using ifelse, since the return

[R] Different output for "if else" and "ifelse" that I don't understand

2017-04-28 Thread Marc Girondot via R-help
Dear list-members, During the test phase of a function, I run it interactively (in Rstudio) and the ... produces an error. Then I use this to read it: if (class(try(list(...), silent=TRUE))=="try-error") p3p <- list() else p3p <- list(...) It works fine; interactively I will get > if