[R] Scale time series in a way that 90% of the data is in the -0.-9/ +0.9 range
Mr.Q
dr.copper2011 at googlemail.com
Thu May 12 15:40:33 CEST 2011
Hello,
How can i scale my time series in a way that 90% of the data is in the
-0.-9/ +0.9 range?
My approach is to first build a clean vector without those 10% far
away from the mean
require(outliers)
y<-rep(c(1,1,1,1,1,9),10)
yc<-y
ycc<-length(y)*0.1
for(j in 1:ycc)
{
cat("Remove",j)
yc<-rm.outlier(yc)
}
and then do my scaling based on the cleaned data
for(k in 1:length(y)) {
y[k]<-(((y[k]-min(yc))/(max(yc)-min(yc)))*1.8)-0.9
}
This works fine for the first three loops, but then strangely crashes :
(
Remove 1Remove 2Remove 3Error in if (xor(((max(x, na.rm = TRUE) -
mean(x, na.rm = TRUE)) < (mean(x, :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In max(x, na.rm = TRUE) :
no non-missing arguments to max; returning -Inf
2: In min(x, na.rm = TRUE) :
no non-missing arguments to min; returning Inf
Any ideas for me?
Thanks in advance,
Mr. Q
More information about the R-help
mailing list