Skip to content
Prev 82542 / 398503 Next

extend.series not zero padding

HELLO ERIC:

	  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

#########################################
HELLO KEITH:

	  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:

dew0<-extend.series(c.,method="zero")

	  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: