0

I am trying to figure out how to use a T/F value to use different functions...

Essentially, I am using the tryCatch function to produce a bunch of results. I have also created a function titled myTryCatch which is essentially the same, but additionally prints out some errors. I would like the user to be able to define whether or not they want to drop the errors, and if so use tryCatch, and if not, use myTryCatch instead (to print out the specific error received). Is there a way to dynamically change which function is used, without a copy/paste of the entire chunk of code (or even relevant bits)?

I suppose the answer may, indeed, be to find the "relevant bits" and only re-type them? Thoughts?

If there's anything I can clarify, please let me know.

ktmbiome
  • 183
  • 1
  • 11
  • You can store a function to a variable. Just assign the function you want to use to a variable that you can call either way. It would be easier to help if you provided a core concrete [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) of what you are trying to do. – MrFlick Sep 23 '16 at 21:50
  • if I'm understanding this..which is a long shot...look at the documentation on readline() which is an interactive catch at the command line. so if your condition is if (!x){x <-readline ("try a new foo")} – Carl Boneri Sep 23 '16 at 22:32

0 Answers0