[R] R: flaw in CRAN package "wavelets": Daubechies "d8" not recognized by function wt.filter

David Winsemius dwinsemius at comcast.net
Wed Mar 4 16:41:32 CET 2009


To see the code (in this case at any rate)  you just type the name of  
the function. I produced a snippet from what appeared on my screen. I  
then copy-pasted to a text-editor, copy-pasted the missing section to  
the d8 segment and assigned the to to wt.filter, which effectively  
overwrote the original and made the new code the working one.

The source of the code will be in the R libraries and is brought in  
from those files at the time the package is loaded. Given that the  
code is just text you can fix it yourself. I just added the missing  
code to a local copy, but a more durable fix would be to edit the files.

The process of getting code when the functions are S3 or S4 functions  
is a bit more complex but there is a very helpful RNews article on  
that topic.

Regarding no response from the author/maintainer: I am not sure you  
have given the process sufficient time.  Perhaps he is on holiday or  
will reply when he gets a free moment.

-- 
David Winsemius


On Mar 4, 2009, at 5:15 AM, <mauede at alice.it> wrote:

> Thank you.
> I do not know where the source code is available.I never uploaded  
> anything to CRAN. I am just an R user so far.
> Can you please tell me ?
>
> I did notify the package maintainer mentioned in the package on-line  
> documentation, namely
>  Eric Aldrich <eldrich at gmail.com>, twice.
> I suspect hic contact information is obsolete because he never got  
> back to me or the R forum.
> Moreover, his web site does not exist and his name cannot be found  
> in the University of Washington directory.
>
> Best regards,
> Maura
>
>
>
> -----Messaggio originale-----
> Da: David Winsemius [mailto:dwinsemius at comcast.net]
> Inviato: mer 04/03/2009 7.20
> A: mauede at alice.it
> Cc: r-help at r-project.org; eldrich at gmail.com
> Oggetto: Re: [R] flaw in CRAN package "wavelets": Daubechies "d8"  
> not recognized by function wt.filter
>
> You can look at the code yourself. The d8 filter appears to have a
> deletion mutation making it "different" than the other d-series and
> the fix looks feasible for testing:
>
> d6.filter <- function(mod = F) {
>              class <- "Daubechies"
>              name <- "d6"
>              L <- as.integer(6)
>              g <- c(0.332670552950083, 0.806891509311093,
> 0.459877502118491,
>                  -0.135011020010255, -0.0854412738820267,
> 0.0352262918857096)
>              if (modwt == TRUE) {
>                  g <- g/sqrt(2)
>                  transform <- "modwt"
>              }
>              else transform <- "dwt"
>              h <- wt.filter.qmf(g, inverse = TRUE)
>              wt.filter <- new("wt.filter", L = L, h = h, g = g,
>                  wt.class = class, wt.name = name, transform =
> transform)
>              return(wt.filter)
>          }
>          d8.filter <- function(mod = F) {
>              class <- "Daubechies"
>              name <- "d8"
>              L <- as.integer(8)
>              g <- c(0.230377813307443, 0.714846570548406,
> 0.630880767935879,
>                  -0.0279837694166834, -0.187034811717913,
> 0.0308413818353661,
>                  0.0328830116666778, -0.0105974017850021)
>
> < missing code>
>
>              h <- wt.filter.qmf(g, inverse = TRUE)
>              wt.filter <- new("wt.filter", L = L, h = h, g = g,
>                  wt.class = class, wt.name = name, transform =
> transform)
>              return(wt.filter)
>          }
>          d10.filter <- function(mod = F) {
>              class <- "Daubechies"
>              name <- "d10"
>              L <- as.integer(10)
>              g <- c(0.160102397974193, 0.60382926979719,
> 0.724308528437773,
>                  0.138428145901320, -0.242294887066382,
> -0.0322448695846381,
>                  0.0775714938400459, -0.0062414902127983,
> -0.012580751999082,
>                  0.0033357252854738)
>              if (modwt == TRUE) {
>                  g <- g/sqrt(2)
>                  transform <- "modwt"
>              }
>              else transform <- "dwt"
>              h <- wt.filter.qmf(g, inverse = TRUE)
>              wt.filter <- new("wt.filter", L = L, h = h, g = g,
>                  wt.class = class, wt.name = name, transform =
> transform)
>              return(wt.filter)
>          }
>
> Make your own wt.filter with the missing code inserted and see if
> happiness prevails.When I apply the fix, I get:
>
>  > wt.filter("d8")
> An object of class "wt.filter"
> Slot "L":
> [1] 8
>
> Slot "level":
> [1] 1
>
> Slot "h":
> [1] -0.01059740 -0.03288301  0.03084138  0.18703481 -0.02798377
> -0.63088077  0.71484657 -0.23037781
>
> Slot "g":
> [1]  0.23037781  0.71484657  0.63088077 -0.02798377 -0.18703481
> 0.03084138  0.03288301 -0.01059740
>
> Slot "wt.class":
> [1] "Daubechies"
>
> Slot "wt.name":
> [1] "d8"
>
> Slot "transform":
> [1] "dwt"
>
>
> By the way, there also appears to be no d2 and calling wt.filter with
> "d2" also provokes an error. The proper manner for getting this
> addressed is to draw it to the attention of the package maintainer
> rather than posting a "to whom it may concern" message to the list.
>
> --
> David Winsemius
>
> On Mar 4, 2009, at 12:36 AM, <mauede at alice.it> <mauede at alice.it>  
> wrote:
>
> >> wt.filter("d8")                                #### HOW COME ????
> > Error in validObject(.Object) :
> >  invalid class "wt.filter" object: invalid object for slot
> > "transform" in class "wt.filter": got class "function", should be or
> > extend class "character"
> >
> >> wt.filter("d10")                             # OK
> > An object of class “wt.filter”
> > Slot "L":
> > [1] 10
> >
> >> wt.filter("d6")                               #OK
> > An object of class “wt.filter”
> > Slot "L":
> > [1] 6
> >
> >
> > Thank you in advance to anyone who takes care of reported  bugs in
> > CRAN packages.
> > Maura
> >
> >
> > tutti i telefonini TIM!
> >
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>
> Alice Messenger ;-) chatti anche con gli amici di Windows Live  
> Messenger e tutti i telefonini TIM!
> Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer
>




More information about the R-help mailing list