[rkward-devel] New plugin and functions
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Apr 26 10:48:23 UTC 2007
Hi,
On Wednesday 25 April 2007, I. Soumpasis wrote:
> > 1.Do you believe that we could/should do it in R or in php?
>
> I dit it with R.
yes, that's best.
> 2. should the y variable take its values like this?
>
> > $yxvarsstring = join (", ", split ("\n", getRK_val ("x")));
> > y=cbindlist (<? echo ($xvarsstring); ?>)
>
> I did like this.
Another option would be to do something like the following (untested):
<?
// in calculate
$yvars = "substitute (" . str_replace ("\n", "), substitute (", trim
(getRK_val ("y"))) . ")";
?>
yvars <- list (<? echo ($yvars); ?>)
res_tables <- list ()
res_names <- c ()
res_chisq <- list ()
for (i in 1:length (yvars)) {
yvar <- eval (yvars[[i]], envir=globalenv ())
res_names[i] <- rk.get.short.name (yvars[[i]], is.substitute=TRUE)
res_tables[i] <- table (x, yvar)
res_chisq[i] <- chisq.test (x, yvar)
}
names (res_tables) <- res_names
<?
// in printout
for (i in 1:length (res_tables)) {
# do the printing, and the barplots
}
?>
The main benefit is that we have information on the names of the variables
available. On the other hand, this can probably be achieved nicely with
cbindlist as well (dimnames(y)[[2]]), I don't have the patience right now to
think this through.
Another concept however, is that it logically separates calculating the
results from printing them, which is a good idea, either way (but can also be
achieved with cbindlist). Also, saving the results to the workspace would
become real easy, now, as there is already one variable holding all the
results.
> 3. What do you believe for the preview option? should it stay or should it
>
> > go?
>
> For the moment I did not remove it but I plan to. If one clicks on preview
> many previews are generated replacing one another stopping on the last
> barplot. Should I remove it, should we leave it as is, or change something?
I think we can deal with this last. It should be possible somehow to show the
preview only for the first pair of variables. But this is just the icing on
the cake. Let's finish everything else, first, then worry about this later.
> I have two problems:
> 1. I get this error.
>
> Error in table(x, y[, i]) : subscript out of bounds
>
> However the results are right. The hours are long right now and I can not
> think the reason.
length(y) returns the number of rows in the matrix, not the number of columns.
In your approach, you'd need dim(a)[2].
> 2.There are some more warnings printed.
>
> Warning messages:
> 1: Chi-squared approximation may be incorrect in: chisq.test(xy)
[...]
> Should and how can we supress them?
Well, they do have a reason, so we should not suppress them. To make them go
away, you could use the simulate.p.value option of chisq.test (should be
optional).
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070426/3797a31d/attachment.sig>
More information about the Rkward-devel
mailing list