"Berton Gunter" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> ?try
>
> as in
>
> result<- try (some R expression...)
> if (inherits(result,'try-error')) ...do something
> else ...do something else

No heaven on earth yet.

how would I incorporate this kind of functionality into
Resultdt<-lapply(PGWide[,240:389], tdt)

everything would have to be built into the tdt spot in the above statement.
How does one get the if...else in there? Does one have to do that as one 
would program a function or could one write the if...else right into 
"Resultdt<-lapply(PGWide[,240:389], tdt)"

This works
> for (few in c(9,10,11,12,243,20)) if 
> (inherits(try(tdt(PGWide[,few])),'try-error')) print("messed up") else 
> print("works")
[1] "works"
[1] "works"
[1] "works"
[1] "works"
Error in rep.default(1, nrow(U)) : rep() incorrect type for second argument
In addition: Warning messages:
1: 1 misinheritances in: phase.resolve(g.cs, g.mr, g.fr, as.allele.pair = 
TRUE, allow.ambiguous = (parent ==
2: 2 misinheritances in: phase.resolve(g.cs, g.mr, g.fr, as.allele.pair = 
TRUE, allow.ambiguous = (parent ==
3: 2 misinheritances in: phase.resolve(g.cs, g.mr, g.fr, as.allele.pair = 
TRUE, allow.ambiguous = (parent ==
4: 4 misinheritances in: phase.resolve(g.cs, g.mr, g.fr, as.allele.pair = 
TRUE, allow.ambiguous = (parent ==
[1] "messed up"
[1] "works"
Warning message:
1 misinheritances in: phase.resolve(g.cs, g.mr, g.fr, as.allele.pair = TRUE, 
allow.ambiguous = (parent ==

BUT THIS DOES NOT

lapply(PGWide[,c(9,10,11,12,,243,20)], if (inherits(try(tdt),'try-error') 
print("messed up") else print("works"))
Error: syntax error in "lapply(PGWide[,c(9,10,11,12,,243,20)], if 
(inherits(try(tdt),'try-error') print"

Any idea why...can it be that one cannot have multiple commands on one line
> p=7 f=8
Error: syntax error in "p=7 f"

in the lapply, how would R know that I was sending the list to tdt?


-- 
Farrel Buchinsky, MD
Pediatric Otolaryngologist
Allegheny General Hospital
Pittsburgh, PA

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to