Re: [R] when vectorising does not work: silent function fail?

2009-11-14 Thread Juliet Hannah
> > Also, you probably get less data copying by using a for() or while() loop > than by using apply() in this context. Why may there be less data copying with "for" and "while" compared to apply? > > Finally, the overhead of formula parsing and model matrix construction > repeated thousands of

Re: [R] when vectorising does not work: silent function fail?

2009-11-10 Thread Federico Calboli
On 10 Nov 2009, at 17:16, tlum...@u.washington.edu wrote: On Tue, 10 Nov 2009, jim holtman wrote: Have you tried something like this: my.results = apply(chr, 2, function(x){ result <- try(anova(lrm( cpstc.f ~ x + time.cpstc + age + sex + mri))[1,3]) if (inherits(result, "try-error")) r

Re: [R] when vectorising does not work: silent function fail?

2009-11-10 Thread tlumley
On Tue, 10 Nov 2009, jim holtman wrote: Have you tried something like this: my.results = apply(chr, 2, function(x){ result <- try(anova(lrm( cpstc.f ~ x + time.cpstc + age + sex + mri))[1,3]) if (inherits(result, "try-error")) return(NULL) result }) This should catch the error and hav

Re: [R] when vectorising does not work: silent function fail?

2009-11-10 Thread jim holtman
Have you tried something like this: my.results = apply(chr, 2, function(x){ result <- try(anova(lrm( cpstc.f ~ x + time.cpstc + age + sex + mri))[1,3]) if (inherits(result, "try-error")) return(NULL) result }) This should catch the error and have NULL in that list element. On Tue, No

[R] when vectorising does not work: silent function fail?

2009-11-10 Thread Federico Calboli
Dear All, I'm using apply to do some genetic association analysis along a chromosome, with many thousands markers. For each marker the analysis is the same, so I was planning to use apply(chrom, 2, somefunction) In the specific case I do: my.results = apply(chr, 2, function(x){anova(lrm( cps