R function fails inside R-Snippet

I'm trying to call a function [bootStepAIC] inside an R-Snippet, whilst it works fine in R-studio, it fails within Knime's R-Snippet.

I believe this is related to this issue:


But I have not been able to get this to work - using "do.call" does not appear to help.

Has anybody got a work-around for this?



Hi Steve,

Could you please post a reproducible example of the R code you are trying to run?



The input is a table of measured xi's and one y-variable;

Knime is linked to MS R Open 3.4

This is the code:


dat <- knime.in

names(dat)<-make.names(names(dat)) #fix column names so [R] won't bomb out.

trg<-make.names(knime.flow.in[["target"]]) # = 'y'

limit<-knime.flow.in[["steps"]] # = 3, prevent over-fit

cn <- names(dat)

xVars<-cn[cn!=trg] # get list of x-vars, x1,x2,x3...


# Even in R-studio, this appears to fail
# unless I put strt<-lm(y~1,dat), but I need to be
# able to build this, as won't always be callled 'y'
# the do.call does not help :-(

bst <- boot.stepAIC(strt,dat,B=50,alpha=0.05,direction='forward',steps=limit,

#the model fit failed in 50 bootstrap samples
#Error: non-character argument

b1 <- bst$Covariates
b2 <- bst$Sign
b3 <- bst$Significance
ball <- cbind.data.frame(b1,b2,b3)

knime.out <- ball


Hi Steve,

What is the error message you are seeing, since you say this also happens in rstudio?



The error is "the model fit failed in 50 bootstrap samples
Error: non-character argument"

This appears to be related to the issue noted in the linked stackoverflow post above, but their "use do.call" fix does not appear to work.

I discovered that having a 'fixed' formula, strt<-lm(y~1,dat), seems to work, so a work-around would to rename the y-variable in Knime before and after the R-script node - but that seems a bit of a kludge.

Does using do.call work in rstudio for you? I'm still not sure whether this is a KNIME - R issue or some issue with the bootStepAIC function. In the stackoverflow post you linked, the problem occurs if the function is called from within another function. This doesn't seem to be the case here, so maybe there is another issue?

do.call does not help in R-Studio either; it looks like a boot.stepAIC issue, so I have contacted the maintainer of the package.

Seems to be related to the class of the 'formula' object in the lm call:

strt1<-lm(y1~1,dat) #works in boot.stepAIC

>[1] "call"

strt2<-do.call("lm",list(frm1,dat)) #fails in boot.stepAIC

>[1] "formula"