Talvez este ejemplo te ayuda:
> test <-rnorm(30)
> id <- rep(c(1, 2), 15)
> id
[1] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
2> text <- capture.output( t.test(test ~ id))
> str(text)
chr [1:12] "" "\tWelch Two Sample t-test" ""
"data: test by id " ...> text
[1] ""
[2] "\tWelch Two Sample t-test"
[3] ""
[4] "data: test by id "
[5] "t = 0.6227, df = 26.058, p-value = 0.5389"
[6] "alternative hypothesis: true difference in means is not equal to 0
"
[7] "95 percent confidence interval:"
[8] " -0.646013 1.207570 "
[9] "sample estimates:"
[10] "mean in group 1 mean in group 2 "
[11] " 0.21496999 -0.06580869 "
[12] ""
Kjetil
2010/5/9 DIEGO LOPEZ <diegocumeiro@hotmail.com>
>
> Hola!
>
> Me gustaría saber si hai alguna forma más eficiente de realizar, lo
> siguiente:
>
> Mi intención es mostrar la salida de R en un widget del tipo tktext, pues
> estoy implementando la interfaz sobre un paquete que muestra algunos
> mensajes en la linea de comandos de R (que quiero que se sigan mostrando).
>
> Pero no encontré una forma más eficiente de realizarlo, que creando un
> archivo .txt y luego leyendo su contenido, espero que alguién pueda decirme
> una forma mejor!!
>
> El codigo sería el siguiente:
>
> sink("miarchivo.txt", append=FALSE, split=FALSE)
> # aquí iría la llamada a la función que muestra mensajes a través de
> los comandos cat.
> sink()
>
>
rutamiarchivoTxt<-paste(getwd(),"/InterfazRHRV.txt",sep="")
> contenidomiarchivoTxt=readLines(rutamiarchivoTxt)
>
> contenidoString<-paste(contenidomiarchivoTxt,collapse="")
> contenidoString<-gsub(" ","\n
",contenidoString)
>
> frameText<-tkframe(tt,relief = "groove", borderwidth = 3)
> tkgrid(frameText,row=18,columnspan=5,padx=2)
> scr <- tkscrollbar(frameText,
> repeatinterval=5,command=function(...)tkyview(txt,...))
> txt <- tktext(frameText,
>
height=3,yscrollcommand=function(...)tkset(scr,...),foreground="blue")
> tkgrid(txt,scr,row=18,columnspan=50)
>
> tkinsert(txt,"end",contenidoString)
> tkgrid.configure(scr,sticky="ns")
>
>
>
> _________________________________________________________________
> Consejos para seducir ¿Puedes conocer gente nueva a través de Internet?
> ¡Regístrate ya!
>
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
--
The good Christian should beware of mathematicians, and all those who make
empty prophecies. The danger already exists that the mathematicians have
made a covenant with the devil to darken the spirit and to confine man in
the bonds of Hell.
St. Augustine, De Genesi ad Litteram, Book II, xviii, 37
[[alternative HTML version deleted]]