[rkward-devel] [rkward-announce] Upcoming release, call for testing RKWard 0.6.0

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Oct 15 11:49:42 UTC 2012


Hi,

thanks for your testing!

On Monday 15 October 2012, SANCHEZ ALBERCA, ALFREDO wrote:
> - In menu Distributions, when I try to calculate some probability tail, if
> you write 0 in the field for quantiles, you get the error: Script error:
> TypeError: Result of expression 'getValue ("q").replace' [undefined] is
> not a function. Inverse trace:
> <anonymous>()@/usr/share/kde4/apps/rkward/distributions/normal_probabilitie
> s.js:5

Indeed. And this is giving me quite a headache, as a similar problem may be 
present in many more plugins (although there are few plugins, where you would 
be likely to enter "0" in a free-text input field).

For some background information, the reason for this bug is that, when 
switching the scripting from PHP to JS (in version 0.5.3), I had added logic 
to getValue() so that the value "0" would always be returned as a number 0, 
not a string. This was needed to keep many plugins working, which are using 
constructs like
   if (getValue ("some_option")) do_something();
In PHP, if some_option had value "0", this would cause the if-clause to be 
false. In Javascript, it would be true, without the special casing. Most of 
the time the special casing is entirely invisible, as Javascript will do 
appropriate type-casting im most places. However, the side-effect that I did 
not think about, it that numbers in Javascript do not have string-specific 
methods like replace() or split().

I'm afraid there is no easy way out of this. I have added a new JS-function 
getString(), which will always return strings, and fixed the distribution 
plugins to use getString(), instead of getValue(). I guess, in the mid-term, 
we'll have to deprecate getValue() altogether, replacing all uses with 
getString(), and getBoolean(). Not quite sure on this, yet.

> - When you load an RData file or import a text or csv data file, you
> couldn't edit it at first. It's necesary to refresh the worksets first.

I tried, but could not reproduce any problem like this. Could you give more 
specific step-by-step instructions on what to do to see the problem?
 
> Proposal:
> - I'm working in a plugin for teaching statistic and I use the javascript
> library mathjax (http://www.mathjax.org/) in order to show formulas (in
> latex or mathml) in the html output page. I put the reference to the
> javascript library in the heading section of the html output, but when I
> clear the output the reference to the javascript library disappear. So, I
> propose to include a new section in the configuration in order to include
> javascript libraries or css style sheets in the head section of the html
> output.

A reasonable suggestion. I have added a parameter to rk.set.output.html.file() 
for this purpose (in the development version, only; this will not be part of 
0.6.0). A new option "rk.html.header.additions" can be used to store a default 
value for this. To use this in all your rkward sessions, you can add
   options (rk.html.header.additions="<script.../>") to Settings->Configure 
RKWard->R-Backend->Further (option) commands...

*However*, there are some caveats to this in your usecase. First, this will 
only affect newly created output files. Second, in general it is not a good 
idea for a plugin to create new output files, or to mess with a user's 
options(). Thus, this will work, only, if you instruct your users to change 
their settings accordingly, *and* start a new output file.

So, if you're looking for a less error-prone solution, I guess you may need to 
trigger loading of the relevant libraries, from a <script> within the <body>-
section of the HTML-document. There are a number of tutorials on the matter on 
the net, e.g. http://unixpapa.com/js/dyna.html .

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20121015/8d75497e/attachment.sig>


More information about the Rkward-devel mailing list