Speaking of spectrum, my face has now been red-shifted.
I guess it's pretty dumb having a variable named 'pi' in a data frame that
I've attached. This is obviously newbie sloppiness, but it raises the
question about how R-guru's manage inadvertent clobbering of magic names.
Constructive suggestions would be warmly received.
Thanks.
Regards,
Mike
----- Forwarded by Michael Nielsen/Syd/Synergy on 19/07/2001 11:22 AM
-----
Michael Nielsen
19/07/2001 11:13 AM
To: r-help at stat.math.ethz.ch
cc:
Subject: Strange behaviour of spectrum()?
Dear r-help list:
In the following R session, I seem to be somehow breaking the spectrum()
function, but I'm not sure how. Could somebody please point out my
mistake? My apologies if it's something that should be obvious.
The mysterious bit is how spectrum(my.ts) at first works, but then later
fails with an error message that I find difficult to interpret.
I'm running R 1.3.0 that I compiled myself on what was once Caldera Linux
(2.2.14), but I dare say I've deviated somewhat from the original Caldera
distribution (added GNOME and generally updated software).
Thanks in advance.
Regards,
Mike
---- session transcript follows ----
R : Copyright 2001, The R Development Core Team
Version 1.3.0 (2001-06-22)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.
R is a collaborative project with many contributors.
Type `contributors()' for more information.
Type `demo()' for some demos, `help()' for on-line help, or
`help.start()' for a HTML browser interface to help.
Type `q()' to quit R.
ls()
character(0)
library(tseries)
`tseries' version: 0.7-4
`tseries' is a package for time series analysis with emphasis
on non-linear modelling.
See `library (help=tseries)' for details.
my.ts<-ts(rnorm(200))
spectrum(my.ts) # nice graphic display appears
plot(my.ts) # another nice graphic display appears
spectrum(my.ts) # As expected, yet another nice graphic display
Error in "[<-"(*tmp*, , i, value = c(w, rep(1, nr - 2 * m), rev(w)) * :
number of items to replace is not a multiple of replacement length
In addition: Warning messages:
1: longer object length
is not a multiple of shorter object length in: pi * seq(1, 2 * m -
1, by = 2)
2: longer object length
is not a multiple of shorter object length in: c(w, rep(1, nr - 2
* m), rev(w)) * x[, i]
spectrum(my.ts) # I would have thought this would have worked
Error in "[<-"(*tmp*, , i, value = c(w, rep(1, nr - 2 * m), rev(w)) * :
number of items to replace is not a multiple of replacement length
In addition: Warning messages:
1: longer object length
is not a multiple of shorter object length in: pi * seq(1, 2 * m -
1, by = 2)
2: longer object length
is not a multiple of shorter object length in: c(w, rep(1, nr - 2
* m), rev(w)) * x[, i]
... it raises the question about how R-guru's manage inadvertent clobbering
of magic names. Constructive suggestions would be warmly received.
Caveat: I am no guru
Suggestion: There is a little function I included in "Kickstarting R"
that might help you.
dup.name<-function(name) {
if(is.character(name))
return(length(grep(name,objects(1:length(search())))) > 0)
cat("Usage: dup.name(name)\n\twhere name is a character string\n")
}
Jim
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Jim" == Jim Lemon <bitwrit at ozemail.com.au> writes:
Jim> MichaelNielsen at synergy.com.au wrote:
>>
>> ... it raises the question about how R-guru's manage inadvertent
>> clobbering of magic names. Constructive suggestions would be warmly
>> received.
you just know the dangerous names and don't reassign them .... :-) ;-)
As a matter of fact, there are only very few global "non-functions"
The following one-liner (:-) shows them :
for(ip in 2:length(search())) {cat("pos = ",ip,": ",search()[ip],"\n========\n");if(length(nms <- ls(pos=ip)))print(nms[sapply(nms,function(n)!is.function(get(n,pos=ip)))])}
pos = 2 : package:ctest
========
character(0)
pos = 3 : Autoloads
========
pos = 4 : package:base
========
[1] ".AutoloadEnv" ".Device" ".Devices"
[4] "F" ".GlobalEnv" "Hershey"
[7] "ISOLatin1" ".Last.value" ".leap.seconds"
[10] "LETTERS" "letters" ".lib.loc"
[13] ".Library" ".Machine" "MacRoman"
[16] "month.abb" "month.name" "native.enc"
[19] ".Options" "p.adjust.methods" ".Pars"
[22] ".Pars.readonly" "pi" ".Platform"
[25] ".PostScript.Options" ".ps.prolog" "R.version"
[28] "R.version.string" "T" "version"
[31] "WinAnsi"
Hence it's
T , F , pi
letters, LETTERS, version, month.name, month.abb, Hershey
(and a few more at most)
that you would care about.
Jim> Caveat: I am no guru
Jim> Suggestion: There is a little function I included in "Kickstarting R"
Jim> that might help you.
Jim> dup.name <- function(name) {
Jim> if(is.character(name))
Jim> return(length(grep(name,objects(1:length(search())))) > 0)
Jim> cat("Usage: dup.name(name)\n\twhere name is a character string\n")
Jim> }
I think you should use the standard function
conflicts()
Martin
Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._