2

I have a R script where some of scripts not run sometimes because of data unavailability. I want to ignore this error so that my script can run on cron schedule.

Script:

data1 = data1 %>% mutate(`04_Days`=paste(round(ifelse(`04 Days` %in% c(NA,"NA"),0,`04 Days`)/`Till date attempted1`*100,0)," %"))

where sometimes the variable 04_Daysis not available and I want to ignore this error while running this line.

Acarbalacar
  • 714
  • 2
  • 7
  • 19
Vishan Rana
  • 307
  • 2
  • 4
  • 9
  • 1
    By not available, do you mean that nothing is assigned to the variable `04_days`, meaning you get a error, that it does not exist? And what package does the `mutate` function come from? – Acarbalacar Sep 05 '17 at 09:00

1 Answers1

2

You can use tryCatch as explained here.

If the code inside tryCatch throws an error, the error function is called. If you want to ignore the error, just leave that function empty.

user2605553
  • 362
  • 1
  • 2
  • 9