当我尝试使用while循环(在末尾)时,它给出的替换长度为零(我也尝试过for循环)。我看到其他与此相关的帖子可以解决此问题,但似乎没有任何工作可做。我正在附上R代码
library(ggplot2)
Data <- readMat("C:\\Users\\syeda\\Desktop\\Reserach PhD\\Data\\gait.mat")
#To separate Knee variable
kne<-Data$knee
knt<-seq(0,1,len=7)
#knt<-knt[2:length(knt)-1]
wbasis <- create.bspline.basis(c(0,1), nbasis=9,norder=4,breaks = knt)
knefdPar <- fdPar(wbasis, 2, 10^(-0.5))
##??##
kneMon <- smooth.monotone(t, rowMeans(kne), knefdPar)
hgtfhatfd <- kneMon$yhatfd
accelfdUN <- deriv.fd(hgtfhatfd, 2)
accelmeanfdUN <- mean(accelfdUN)
PGSctr <- rep(0,39)
agefine <- seq(0,1,len=200)
par(mfrow=c(1,1), ask=TRUE)
for (icase in 1:39) {
accveci <- predict(accelfdUN[icase], agefine)
plot(agefine,accveci,"l", ylim=c(-10,80),
xlab="Year", ylab="Height Accel.",
main=paste("Case",icase))
lines(c(0,1),c(0,0),lty=2)
PGSctr[icase] = locator(icase)$
print(PGSctr[icase])
}
i<-1
while (i<40) {
accveci <- predict(accelfdUN[i], agefine)
plot(agefine,accveci,"l", ylim=c(-10,80),
xlab="Year", ylab="Height Accel.",
main=paste("Case",i))
lines(c(0,1),c(0,0),lty=2)
PGSctr[i] <- locator(1)$x
#print(locator(i)$x)
i<-i+1
}