首页 > 解决方案 > 如何修复 UseMethod("filter") 中的错误?它仍然得到平均线

问题描述

summary(Bird_Data1)
temp<-scan("Bird_Data1.txt")
year<-seq(from=2002,by=1.0/6,length=length(temp))
plot(year, temp,type="l",
     xlab="year", ylab="monthly winter temperature",col="blue",pch="*")
d<-6
half.d<-d/2
our.filter<-c(0.5,rep(1,d-1),0.5)/d
our.filter
n<-length(temp)
longer.temp<-c(temp[(d/2):1],temp,temp[n:(n-d/2+1)])
longer.temp
temp.MA<-filter(longer.temp,our.filter)[(d/2+1):(d/2+n)]
temp.MA
plot(year,temp,type="l",xlab="year",ylab="monthly winter tempature")
lines(year,temp.MA,type="l",lwd=2,col="blue",pch="*")`

#what is the problem of bold one? it stated"[\[][1]Error in UseMethod("filter") : 
  no applicable method for 'filter' applied to an object of class "c('double', 'numeric')""]

#我想生成10年以上温度的中心加权移动平均值出现一些问题 在此处输入图像描述

标签: weighted

解决方案


推荐阅读