我的程序如下:
rt=read.csv("hppmi.csv")
y=rt[,1]
x=rt[,2]
library(np)
#package np, nonparametric andsemiparametric kernel methods
library(np)
h1=npregbw(formula=y~x); h1
fit1<-npreg(bws=h1,txdat=x,tydat=y)
plot(x,y)
points(x,y)
> h2=dpill(x,y); h2错误于if (from == to) rep.int(from, length.out) else as.vector(c(from, : 需要TRUE/FALSE值的地方不可以用缺少值> fit2<-locpoly(x,y,bandwidth=h2)错误于if (from == to) rep.int(from, length.out) else as.vector(c(from, : 需要TRUE/FALSE值的地方不可以用缺少值> plot(x,y)> lines(fit2)> #first order derivatives> order1<-locpoly(x,y,bandwidth=h2,drv=1)错误于if (from == to) rep.int(from, length.out) else as.vector(c(from, : 需要TRUE/FALSE值的地方不可以用缺少值> plot(order1$x,order1$y,type='l')#first order derivativesorder1<-locpoly(x,y,bandwidth=h2,drv=1)plot(order1$x,order1$y,type='l')
程序中我并没有用到if语句,为什么出现错误呢???求教