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-boun...@r-project.org] On Behalf Of Steven Spiriti Sent: 24 May 2018 21:11 To: r-package-devel@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: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: coef.freekt > ### Title: Compute Coefficients of B-Splines For Free-Knot Splines > ### Aliases: coef.freekt > ### Keywords: nonparametric regression smooth > > ### ** Examples > > x <- 0:30/30 > truey <- x*sin(10*x) > set.seed(10556) > y <- truey + rnorm(31, 0, 0.2) > xy.freekt <- freelsgen(x, y, degree = 2, numknot = 2, 555) > coef(xy.freekt) 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@x ydat <- object@y optknot <- object@optknot ord <- object@degree + 1 lambda <- object@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 [[alternative HTML version deleted]] ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel