0

I'm developing an application for simulating experiments and I need to know how to include the result of an analysis (say ANOVA) into a gwidget area. I can deal with plots (including ggplots), but I cannot find how to manage the output of an analysis.

I'll apprciate any suggestion.

Thanks a lot.

leppie
  • 115,091
  • 17
  • 196
  • 297
alsote
  • 1
  • 1
  • @spacedman's answer is spot on. You likely want to use a monospace font. Something like this pattern: `insert(t, capture.output(a), font=list(family="monospace"))` where `t` is a `gtext` object and `a` your object to display. – jverzani Feb 07 '14 at 22:00

1 Answers1

0

The help for any analysis function should tell you what it returns, or how to access that information. For example, a glm:

> d=data.frame(x=1:10,z1=runif(10),z2=(1:10)+rnorm(10,0,1))
> g = glm(x~z1+z2,data=d)

then

> summary(g)$coeff
             Estimate Std. Error    t value     Pr(>|t|)
(Intercept) 0.3875693  0.7895574 0.49086906 0.6385324013
z1          0.1182509  1.8060941 0.06547326 0.9496278349
z2          0.9490186  0.1665428 5.69834785 0.0007366074

which is really just a matrix:

> ms = summary(g)$coeff
> ms[1,]
  Estimate Std. Error    t value   Pr(>|t|) 
 0.3875693  0.7895574  0.4908691  0.6385324 

so you can get the values and put them in your widgets as text, or if your widget toolkit has a grid component, one of those.

Or if you just want the text output, use capture.output:

txt = capture.output(summary(g))

and that gives you a vector of text lines that you can put into a widget toolkit text area.

Spacedman
  • 92,590
  • 12
  • 140
  • 224