[R] Possible bug in apply()
mikalzet@libero.it
mikalzet at libero.it
Sun Oct 8 18:41:22 CEST 2000
At my first attempt I got an early syntax error code:
very silly of me - a misplaced bracket.
On Sat, 7 Oct 2000, Clive Jenkins wrote:
> Error in names(x) == ans.names : comparison (1) is possible only for
> vector types
If I load c.test library before running your code and check to see it's
'distr.dat' everytime instead of 'dist.dat' I get the same reply.
> If we look at the structure of the value returned by shap() for the
> first sample, we see that W has a "names" attribute whereas p has
> not (or its "names" attribute is the empty string):
>
> > str(shap(dist.dat[1,]))
> Named num [1:2] 0.887519 0.000622
> - attr(*, "names")= chr [1:2] "W" ""
Same reply
> but in the case of the second sample (all NA except one), shapiro.test()
> was not called, and the preset default value c(NA, NA) returned:
>
> > str(shap(dist.dat[2,]))
> logi [1:2] NA NA
Same reply
> Looking directly at the result of shapiro.test(), we get:
>
> > str(shapiro.test(dist.dat[1,]))
> List of 4
> $ statistic: Named num 0.888
> ..- attr(*, "names")= chr "W"
> $ p.value : num 0.000622
> $ method : chr "Shapiro-Wilk normality test"
> $ data.name: chr "dist.dat[1, ]"
> - attr(*, "class")= chr "htest"
Idem
> If I remove the "names" attribute from W by changing the line
> of code marked "# Problem line" to
>
> result.W <- as.numeric(shap.res$statistic)
>
> the error disappears.
Right. I get the following output:
[,1] [,2]
[1,] 0.8875191054 NA
[2,] 0.0006219975 NA
If it is a bug it's replicable on i586 linux-mandrake R-1.1.1 .
--
Dr. Michele Alzetta
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list