try command in R
1
0
Entering edit mode
6.9 years ago
anu014 ▴ 190

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 • 1.9k views
ADD COMMENT
1
Entering edit mode

Maybe this helps: http://mazamascience.com/WorkingWithData/?p=929

However, I would post this on Stack Overflow, this sounds much more like a general IT question than a bioinformatics one.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
6.9 years ago
e.rempel ★ 1.1k

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

ADD COMMENT

Login before adding your answer.

Traffic: 2809 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6