[R] extend.series not zero padding

Spencer Graves spencer.graves at pdf.com
Sat Dec 10 03:12:38 CET 2005


	  The documentation for "extend.series" indicates that "zero" is an 
option for "method".  However, consider the followining:

 > extend.series(c(0, pi), method="zero")
Error in extend.series(c(0, pi), method = "zero") :
	Invalid argument value for 'method'

	  If you replace "zero" with "zeros" in the documentation, it will be 
consistent with the actual function behavior:

 > extend.series(c(0, pi), method="zeros")
[1] 0.000000 3.141593 0.000000 0.000000


	  Permit me to outline for your general edification how I found this. 
First, I installed "wavelets" and replicated your error.  I  noticed 
that your sample series was named "c".  Since that's also a function 
name, I replaced "c" with "c.".  That did not fix the error.  However, I 
generally avoid using the names of standard functions for other 
purposes.  In most but not all cases, R can tell from the context 
whether the function or the non-function object 'c' should be used.  To 
avoid being trapped by this in the occasionally cases where R can NOT 
tell the difference, I routine type a variabile name at a command prompt 
before using it:  If I get 'object not found', I feel more comfortable 
using it.  If R returns something, I tend to avoid that name.

	  Next, I tried to simplify your example.  I determined from the 
documnetation that we should be able to delete the last two arguments 
and still get the same thing.  I therefore tried the following:


	  When I got the same error message, I then listed the function by 
typing "extend.series" at a command prompt and copied the text into a 
script file so I could look at it.

	  Then I invoked "debug(extend.series)" and tried the 
'dew0<-extend.series(...)" command again.  From this, I found it failed 
on the following:

     if (is.na(match(method, c("periodic", "reflection", "zeros",
         "mean", "reflection.inverse"))))
	  I then tried it with "method='zeros'", and it worked.

	  Then, in preparing an email to Eric Aldrich, I simplified the example 
still further to make it easier for him to understand the issue.

	  hope this helps.
	  spencer graves

Keith Chamberlain wrote:

> Dear List,
> I was trying to verify that I could use extend.series in the wavelets
> package and kept getting an error when trying to use method="zero". I'm not
> seeing where my syntax has gone awry.
> According to the documentation, [see ?extend.series]
> "  method: A character string indicating which extension method to use.
>           Possible values are '"periodic"', '"reflection"', '"zero"',
>           '"mean"', and '"reflection.inverse"'."
> c<-cbind(0:60, 60:0) # setup a series, length will be 61
> [1] 122
> j=log(length(c),2)%/%1)
>>Error in extend.series(c, method = "zero", length = "powerof2", j =
> log(length(c),  : 
>         Invalid argument value for 'method'
> Other methods work great, such as method="mean".
> j=log(length(c),2)%/%1)
> [1] 128
> Has this come up in anyone else's experience? If so, what's the workaround
> so that I can use "zero" as a method?
> Rgds,
> KeithC.
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915

More information about the R-help mailing list