Well, the computer is very good at doing what we ask it to, not what we intend to.
In your case coef.freekt() clearly expects an S4 object (clue: object@) and apparently that's what you feed it with.
A simple way to see where the problem actually comes from is
options(error=recover)
coef(xy.freekt)
Then explore what is going on.
Georgi Boshnakov
-----Original Message-----
From: R-package-devel [mailto:r-package-devel-bounces at r-project.org] On Behalf Of Steven Spiriti
Sent: 24 May 2018 21:11
To: r-package-devel at r-project.org
Subject: [R-pkg-devel] Errors in my package
To Whom It May Concern:
I have created a package called "freeknotsplines" in R, and I need to
make a few updates to it. I resubmitted the package, and received the
following error message:
checking examples ... ERROR
Running examples in ?freeknotsplines-Ex.R? failed
The error most likely occurred in:
Error: $ operator not defined for this S4 class
Execution halted
This error occurs in one of the examples in the documentation. It is
platform dependent, and does not occur on the machine I am using to create
the package. freekt is a new class, which is intended to be a S3 class,
not a S4 class.
Here is the code for coef.freekt:
coef.freekt <- function(object, ...)
{
xdat <- object at x
ydat <- object at y
optknot <- object at optknot
ord <- object at degree + 1
lambda <- object at lambda
fulloptknot <- c(rep(min(xdat), ord), optknot, rep(max(xdat), ord)) #
includes endpoints
Xmat <- splineDesign(fulloptknot, xdat, ord)
if ((lambda == 0) | (length(optknot) == 0))
coef <- solve(t(Xmat)%*%Xmat, t(Xmat)%*%ydat)
else
{
numknots <- length(optknot)
Amat <- chgbasismat(fulloptknot, ord)
Istar <- diag(c(rep(0, times = ord), rep(1, times = numknots)))
coef <- solve(t(Xmat)%*%Xmat + lambda*t(Amat)%*%Istar%*%Amat,
t(Xmat)%*%ydat)
}
return(coef)
}
Can someone please help me figure out what I am doing that is causing this
error?
Sincerely,
Steven Spiriti
______________________________________________
R-package-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel