tryCatch in R [Software]

posted by mittyri – Russia, 2022-08-31 19:53 (393 d 22:40 ago) – Posting: # 23245
Views: 1,171

Hi ElMaestro,

❝ You can try the following simpler example:

a=system(command="hamburger", intern=T)

❝ The following is printed to the console:

sh: 1: hamburger: not found

❝ Error in system(command = "hamburger", intern = T) :

❝ error in running command

❝ But this isn't the content of the variable a as I was hoping. Note that in this example, an error is produced but not in the R sense, only in the system (or system2) sense. Thus, there is no gain in putting the code into try{} brackets.


maybe I misunderstood your goal but won't
tryCatch(
  {   
    a <- system(command="hamburger", intern = T)
  }, 
  error = function(cond) {
    a <<- cond
  }
)

work?

Kind regards,
Mittyri

Complete thread:

UA Flag
Activity
 Admin contact
22,763 posts in 4,775 threads, 1,627 registered users;
13 visitors (0 registered, 13 guests [including 5 identified bots]).
Forum time: 18:33 CEST (Europe/Vienna)

A little Learning is a dang’rous Thing;
Drink deep, or taste not the Pierian Spring:
There shallow Draughts intoxicate the Brain,
And drinking largely sobers us again.    Alexander Pope

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5