0

I am sorry to ask this here....but I do need your help.

I am creating a form. The codes are:

define laglist and varlist

 laglist <- list(list(fun="ns", degree=2,int=TRUE),
    list(fun="ns", degree=3,int=TRUE),
    list(fun="bs",degree=2,int=TRUE),
    list(fun="bs",degree=3, int=TRUE))
    laglist <- rep(laglist,2)
    varlist <- list(list(fun="ns", degree=2, knots=c(52.19, 82.51,237.02),int=TRUE),
    list(fun="ns", degree=3, knots=c(52.19, 82.51,237.02),int=TRUE),
    list(fun="ns",degree=4,knots=c(52.19, 82.51,237.02),int=TRUE))
    varlist <- varlist[c(rep(1,4),3,2,3,3)]

Creating the form

 for(i in 1:4) {
    tab2a[i,1:2] <- c(argvar=varlist[[i]],arglag=laglist[[i]])
    cb1 <- crossbasis(AFH6,lag=c(2,24), argvar=varlist[[i]],arglag=laglist[[i]])
    tab2a[i,3] <- ncol(cb1)
    model<- lm(NH3cH6~cb1+ns(DenH6,15)+ns(HenageH6,11)+as.factor(LightH6)+as.factor(Time))
    tab2a[i,4] <- formatC(AIC(model),digits=1,format="f")
    tab2a[i,5] <- formatC(BIC(model),digits=1,format="f") }

But there are always says:error in "tab2a[i, 1:2] <- c(argvar = varlist[[i]], arglag = laglist[[i]])" number of items to replace is not a multiple of replacement length.

I don't know how to fix it. Hope you can help me! Thanks a lot!!

user26221
  • 33
  • 5
  • 1
    Welcome to SO. You are much more likely to receive a helpful answer if you provide a small data set that people can try their code on. Please provide a [**minimal, reproducible example**](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). Cheers. – Henrik Feb 03 '14 at 19:31
  • 1
    Take a look at what `c(argvar=varlist[[i]],arglag=laglist[[i]])` returns. Is it two elements? (no). You haven't defined `tab2a` anywhere, but you're trying to make it be a dataframe. If each element is a list, then you're trying to assign a single list to two locations. – Carl Witthoft Feb 03 '14 at 20:14

0 Answers0