This is a test version of Biostars. For the public version, visit https://www.biostars.org.
try command in R

Hi all,

Can anyone tell me how to use 'try' command for a block of commands? Right now I'm using try for each command like this :

try(m<-MAplot(genes(cuff),args[1],args[2]))
try(png('MA_plot.png'))
try(m)
try(dev.off ())
try(print("MA_plot"))

Please help. Thanks :)

r

Yeah. That's true. Have to take care next time.. Thanks for answering anyways :)

1 answer

Hi,

quick Google search redirected me to the book of Hadley Wickham. Here he suggests:

To pass larger blocks of code to try(), wrap them in {}:

try({
a <- 1
b <- "x"
a + b
})

HTH

Log in to answer this question.