[RkWard-devel] quantile plug-in

Stefan Rödiger stefan_roediger at gmx.de
Sat Feb 18 23:43:45 UTC 2006


Pierre Ecochard wrote:
> Hi Stefan,
>
> There are R functions in RKWard that are intended to help you producing HTML 
> output. They rely on R2HTML, which can be easily installed from the CRAN.
>
> For example, in you case, you would run the following code inside RKWard:
> a=c(1,2,3,4,5,6,7,8,9,10)
> q=quantile(a, probs=seq(0,1,0.1))
> rk.print(q)
>
> Then you use the "output->refresh" menu and you can see that in the rkward 
> output you have a nice HTML table with the 'names' attribute taken into 
> account.
>
> You may also want to look at rk.graph.on() and rk.graph.off().
>
> Pïerre
>
>
> Le Samedi 18 Février 2006 12:53, Stefan Rödiger a écrit :
>   
>> Hi RKWardians,
>>
>> I have a new question. Right now I'm working on a quantile plug-in. So
>> far it is working but I can not figure out how to apply the "names"
>> attribute within the HTML output. It's important because I use
>> user-defined sequences for the probabilities e.g. seq(0,1,0.1) equals
>> 0%, 10%, 20%, ..., 90%, 100%. This means if the user "needs" more then
>> the common quartiles (0,1,0.25) he can also apply finer increments.
>>
>> Example:
>>
>> In R is the code:
>>
>> a=c(1,2,3,4,5,6,7,8,9,10)
>> quantile(a, probs=seq(0,1,0.1))
>> 0%  10%  20%  30%  40%  50%  60%  70%  80%  90% 100%
>>  1.0  1.9  2.8  3.7  4.6  5.5  6.4  7.3  8.2  9.1 10.0
>>
>> In RKWard (php):
>> //a corresponds to <? getRK ("x"); ?>
>>
>> <?
>>     function preprocess () {
>>     }
>>
>>     function calculate () {
>> ?>rk.temp = quantile (<? getRK ("x"); ?>, na.rm= <? getRK ("narm"); ?>,
>> type = <? getRK ("samplequantile"); ?>, name = <? getRK ("names"); ?>,
>> probs = seq(<? getRK ("probs1"); ?>, <? getRK ("probs2"); ?>, <? getRK
>> ("probs3"); ?>))
>>
>> rk.temp.date = date()
>> <?
>>     }
>>
>>     function printout () {
>>
>>         //fetch some values from RKWard and assign some PHP-variables
>>
>>         $x = getRK_val ("x.shortname");
>>
>>         //produce the output
>> ?>
>> cat ("<h1>Quantile</h1>")
>>
>>     cat ("<table border = \"1\">")
>>         cat ("<TR><TD>Method:</TD><TD><? getRK ("samplequantile");
>> ?></TD><TD>na.rm: <? getRK ("narm"); ?></TD></TR>")
>>         cat ("<TR><TD>created:</TD><TD>",rk.temp.date,"</TD></TR>")
>>             cat ("<TR><TD></TD></TR>")
>>         cat ("<TR><TD>Variable</TD><TD>quantile</TD></TR>")
>>         cat ("<TR><TD>dummy</TD><TD>", rk.temp,"</TD></TR>")
>>     cat ("</table>")
>> <?
>>     }
>>
>>     function cleanup () {
>> ?>
>> rm (rk.temp)
>> rm (rk.temp.date)
>> <?
>>     }
>> ?>
>> ...
>>
>> But "0%  10%  20%  30%  40%  50%  60%  70%  80%  90% 100%" will not be
>> shown within the table. What must be done to get it working?
>>
>>     
>
>   
Hi Pierre,

I wasn't aware of such a functionality. It's good to know that it is 
working this way. I'll check it and answer how it worked out.
BTW, I had troubles to load the R2HTML. I had the error message:
"--- Please select a CRAN mirror for use in this session ---
Error in file(file, "r") : unable to open connection
In addition: Warning message:
cannot open file '/usr/lib/R/doc/CRAN_mirrors.csv', reason 'Datei oder 
Verzeichnis nicht gefunden' "
which simply means that the file was not found. As stated by the RKWard 
error message it was not there. Can anybody send me a copy of this file? 
In the meantime I downloaded a *.deb from an other server.

Cheers!
Stefan




More information about the Rkward-devel mailing list