[R] Help with Using gtext in gWidgetsWWW for Outputting Results to Webpage

Ron Fricker rdfricker at nps.edu
Sat May 7 03:10:01 CEST 2011


All:  Using gWidgetsWWW, I'm in the process of designing a website that will
provide users with a GUI to interact with various datasets.  As part of
that, I want to provide users the ability select particular variables (via
combo boxes) that will then result in summary (text) output being returned
to the webpage.  Think of it as their choices ultimately result in a one- or
two-way table being returned from the R table() function.

The way I have implemented it is with a series of comboboxes that users use
to make selections and that ultimately return table() output to a gtext
widget.  In so doing, I was essentially following the example at the end of
"Examples for gWidgets" (Section 17.2, An alternative to ggenericwidget). 
Right now I'm testing the code on my local PC using localServerOpen().  

The problem is not with the function, but with the output.  Specifically, in
the output the formatting (particularly newline returns) are stripped out
and my table turns into a long string of numbers.  Similarly, any text that
I add to the gtext widget is just appended.  So, I just get a long string of
text and numbers that is essentially unintelligible.

What I want is output similar to what I would see in the R Console were I to
generate a table there.  In an attempt to correct this, I have tried all
manner of font options such as font.attr=c("monospace"), etc., and it seems
that no matter what I try I can neither affect the displayed font (it's some
sort of proportional Arial-like font) nor the exclusion of line returns. 
(When I include \n in the text, it's simply stripped out/ignored.  However,
\t works.)

Now, when I run the same code under gWidgets, I get a Courier-style font and
the line returns show up.  That is, the output in the gtext widget looks
much like I would see in the R Console.  So, my guess is that the browser is
overriding the gWidgetsWWW output.  I'm running this in the latest version
of Firefox.  (When I ran the same code using IE 9.0, the gtext widget does
not even show up, but that's a different issue...)

With all that as background, two questions:

(1) Is the use of the gtext widget a good approach for what I want to do, or
is there a better approach?

(2) If the gtext widget is the way to go, any suggestions for solving the
above problem?

Many thanks,
Ron

-----
Associate Professor
Operations Research Dept.
Naval Postgraduate School
Monterey, CA, USA
--
View this message in context: http://r.789695.n4.nabble.com/Help-with-Using-gtext-in-gWidgetsWWW-for-Outputting-Results-to-Webpage-tp3504688p3504688.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list