[R-pkg-devel] Errors in my package

Duncan Murdoch murdoch@dunc@n @ending from gm@il@com
Thu May 24 23:40:27 CEST 2018


On 24/05/2018 4:11 PM, Steven Spiriti wrote:
> 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.

But you are using the @ operator on it:

> 
>   Here is the code for coef.freekt:
> 
> coef.freekt <- function(object, ...)
> {
>    xdat <- object using x
>    ydat <- object using y

That's normally something that you would do with an S4 object.  We can't 
tell from your posting what xy.freekt really is; maybe it would help if 
you posted the result of str(xy.freekt) after creating it.

Duncan Murdoch


>    optknot <- object using optknot
>    ord <- object using degree + 1
>    lambda <- object using 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 using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list